Handling a colon in an element ID in a CSS selector

sblundy picture sblundy · Sep 23, 2008 · Viewed 52.9k times · Source

JSF is setting the ID of an input field to search_form:expression. I need to specify some styling on that element, but that colon looks like the beginning of a pseudo-element to the browser so it gets marked invalid and ignored. Is there anyway to escape the colon or something?

input#search_form:expression {
  ///...
}

Answer

Mark Cidade picture Mark Cidade · Sep 23, 2008

Backslash:

input#search_form\:expression {  ///...}