You are here: Reference > CSS > selectors and pseudos

Selectors and Pseudos

Selector Support Description
*
Applies to any element, Universal selector.
E
Applies to an element of type E (E is a the name of the node).
.className
Applies to any element whose class attribute value is equal to className.
#myID
Applies to any element whose ID attribute value is equal to myID.
E.className
Applies to an element of type E whose class attribute value is equal to className.
E#myID
Applies to an element of type E whose ID attribute value is equal to myID.
E[attr]
7
Applies to an element of type E with an "attr" attribute.
E[attr="val"]
7
Applies to an element of type E with an "attr" attribute equal to "val".
E[attr*="val"]
7
Applies to an element of type E with an "attr" attribute and whose value contains at least one occurance of string "val".
E[attr~="val"]
7
Applies to an element of type E whose "attr" attribute value is a list of space-separated values, and at least one is equal to "val".
E[attr|="val"]
7
Applies to an element of type E whose "attr" attribute value is a list of hyphen-separated values, and at least one is equal to "val".
E[attr^="val"]
7
Applies to an element of type E with an "attr" attribute and whose value begins exactly with "val".
E[attr$="val"]
7
Applies to an element of type E with an "attr" attribute and whose value ends exactly with "val".
E F
Applies to an F element which is a descendant of an E element.
E > F
7
Applies to an F element which is a direct child of an E element.
E + F
7
Applies to an F element which is immediately preceded by an E element.
E ~ F
7
Applies to an F element which is a preceded by an E element.
Pseudo elements
::after
8
Can be used to specify generated content after an element's contents.
::before
8
Can be used to specify generated content before an element's contents.
::first-letter
Applies to the first letter of an element.
::first-line
Applies to the first line of an element.
::selection
Applies to the content that is currently selected or highlighted text by the user.
Structural pseudo-classes
:empty
9
Applies to elements that do not have any content.
:first-child
Applies to any element that is the first child of its parent.
:first-of-type
93.5
Applies to any element that is the first child of its type in its parent.
:last-child
9
Applies to any element that is the last child of its parent.
:last-of-type
93.5
Applies to any element that is the last child of its type in its parent.
:nth-child ()
93.5
Applies to any element that is the n-th child of its parent.
:nth-last-child ()
93.5
Applies to any element that is the n-th child of its parent, counting from the last one.
:nth-of-type ()
93.5
Applies to any element that is the n-th sibling of its type.
:nth-last-of-type ()
93.5
Applies to any element that is the n-th sibling of its type, counting from the last one.
:only-child
9
Applies to any element that is the only child of its parent.
:only-of-type
93.5
Applies to any element that is the only sibling of its type.
:root
9
Applies to the top-level element of a document.
Link pseudo-classes
:link
Applies to unvisited links (A tag with specified href attribute).
:visited
Applies to visited links ('A' tag with specified 'href' attribute, that has been visited by the user before).
:target
9
Applies to the element which is the target of the current document's URI.
Dynamic pseudo-classes
:active
Applies to the currently engaged or active element within the document.
:focus
8
Applies to the currently focused element.
:hover
Applies to the element whereon the mouse pointer is currently over.
State pseudo-classes
:enabled
9
Applies to standard user interface elements that are enabled to use by the user.
:disabled
9
Applies to standard user interface elements that are disabled.
:checked
9
Applies to element which is in checked state.
:indeterminate
93.6
Applies to element which is in indeterminate state.
:default
3
Applies to default user interface elements.
Language pseudo-class
:lang
8
Applies to elements with the specified language setting.
Negation pseudo-class
:not()
9
Used to negate a normal selector.
User Contributed Comments

Post Content

Post Content