| Expression |
Name |
Description / Example |
| * |
Universal selector |
Matches any element |
| E |
Type selector |
Matches any E element (i. e. an element with the local name
E) |
| E F |
Descendant selector |
Matches any F element that is a descendant of an
E element. |
| E > F |
Child selectors |
Matches any F element that is a child of an element
E. |
| E:first-child |
The :first-child pseudo-class |
Matches element E when E is the first child of
its parent. |
| E:lang(c)
|
The :lang() pseudo-class |
Matches element of type E if it is in (human) language
c (the document language specifies how language is determined).
|
| E + F |
Adjacent selector |
Matches any F element immediately preceded by a sibling element
E. |
| E[foo] |
Attribute selector |
Matches any E element with the "foo" attribute
set (whatever the value). |
| E[foo="warning"] |
Attribute selector |
Matches any E element whose "foo" attribute value
is exactly equal to "warning". |
| E[foo~="warning"] |
Attribute selector |
Matches any E element whose "foo" attribute value
is a list of space-separated values, one of which is exactly equal to
"warning". |
| E[lang|="en"] |
Attribute selector |
Matches any E element whose "lang" attribute has
a hyphen-separated list of values beginning (from the left) with "en".
|
| E:before and E:after |
Pseudo elements |
The ':before' and ':after' pseudo-elements can be
used to insert generated content before or after an element's content. |
| E[att^="val"] |
CSS 3 attribute selector |
An E element whose att attribute value begins exactly with the
string val. |
| E[att$="val"] |
CSS 3 attribute selector |
An E element whose att attribute value ends exactly with the
string val. |
| E[att*="val"] |
CSS 3 attribute selector |
An E element whose att attribute value contains the substring
val. |
| E:root |
CSS 3 pseudo-class |
Matches the root element of the document. In HTML, the root element is always the
HTML element. |
| E:empty |
CSS 3 pseudo element |
An E element which has no text or child elements. |