CSS Selectors
This section contains a list of selectors available for Cascading Style Sheets (CSS).
Selectors
Class SelectorMatches the class attribute of the specified element.
Equality [=] Attribute SelectorExactly matches the specified attribute value.
Existence [] Attribute SelectorMatches the attribute, whatever its value.
Hyphen [|=] Attribute SelectorMatches any attribute value that is exactly equal, or optionally, followed by a hyphen.
ID SelectorMatches the id attribute of the specified element.
Prefix [^=] Attribute SelectorMatches the specified prefix of an attribute value.
Substring [*=] Attribute SelectorMatches the specified substring of an attribute value.
Suffix [$=] Attribute SelectorMatches the specified suffix of an attribute value.
Type SelectorMatches any element of the specified type.
Universal (*) SelectorMatches any element type.
Whitespace [~=] Attribute SelectorExactly matches the specified attribute value in a space-delimited list of values.
Pseudo-classes
:activeSets the style of an element when it is engaged or active.
:checkedApplies one or more styles to the form control element that is selected.
:disabledApplies one or more styles to the form control element that is disabled.
:emptyApplies one or more styles to the element that has no child elements (including text nodes).
:enabledApplies one or more styles to the form control element that is enabled.
:first-childApplies one or more styles to any element that is the first child of its parent.
:first-of-typeApplies one or more styles to the element that is the first sibling element of its type.
:focusSets the style of an element when it gains focus.
:hover
Sets the style of an element when the user hovers the mouse pointer over the element.
:indeterminateApplies one or more styles to radio buttons and check boxes whose toggle states cannot be determined—they are neither checked (selected) nor unchecked (cleared).
:lang(C)In a document, selects the elements that are in a given language.
:last-childApplies one or more styles to the element that is the last child element of its parent element.
:last-of-typeApplies one or more styles to the element that is the last sibling element of its type.
:linkSets the style of an a element when the link has not been visited recently.
:not(s)Applies one or more styles to elements that do not match the simple selector s.
:nth-child(n)Applies one or more styles to the element that is the n-th child of its parent element.
:nth-last-child(n)Applies one or more styles to the element that is the n-th child of its parent element, counting from the last one.
:nth-last-of-type(n)Applies one or more styles to the element that is the n-th sibling of its type, counting from the last one.
:nth-of-type(n)Applies one or more styles to the element that is the n-th sibling of its type.
:only-childApplies one or more styles to the element that is the last sibling element of its type.
:only-of-typeApplies one or more styles to the element that is the only sibling element of its type.
:rootApplies one or more styles to the element that is the root element of the document.
:targetApplies one or more styles to the target element of of the referring Uniform Resource Identifier (URI).
:visitedSets the style of an A element if the link has been visited recently.
Pseudo-elements
:selectionApplies one or more styles to any text on the page that the user has highlighted.
:afterDefines generated content that appears after an element.
:beforeDefines generated content that appears before an element.
:first-letterApplies one or more styles to the first letter of the object.
:first-lineApplies one or more styles to the first line of the object.
Combinators
Adjacent Sibling (+) CombinatorSpecifies an adjacent sibling relationship between selector elements.
Child (>) CombinatorSpecifies a direct descendant relationship between selector elements.
Descendant CombinatorSpecifies an arbitrary ancestral relationship between selector elements.
General Sibling (~) CombinatorSpecifies a general sibling relationship between selector elements.