Selectors and combinators
This section contains a list of selectors available for cascading style sheets.
Selectors
Class selector Matches the class property of the specified element.
Equality attribute selector Exactly matches the specified property value.
Existence attribute selector Matches the property, whatever its value.
Hyphen attribute selector Matches any property value that is exactly equal or, optionally, is followed by a hyphen.
ID selector Matches the class property of the specified element.
Prefix attribute selector Matches the specified prefix of a property value.
Substring attribute selector Matches the specified substring of a property value.
Suffix attribute selector Matches the specified suffix of a property value.
Type selector Matches any element of the specified type.
Universal selector Matches any element type.
Whitespace attribute selector Exactly matches the specified property value in a space-delimited list of values.
Pseudo-classes
:active Sets the style of an A element when the link is engaged or active.
::after Defines generated content that appears after an element.
::before Defines generated content that appears before an element.
:checked Applies one or more styles to the form control element that is selected.
:disabled Applies one or more styles to the form control element that is disabled.
:empty Applies one or more styles to the element that has no child elements (including text nodes).
:first-child Applies one or more styles to any element that is the first child of its parent.
:first-of-type Applies one or more styles to the element that is the first sibling element of its type.
:focus Sets the style of an element when it gains focus.
:hover Sets the style of an element when the user rests the pointer on the element.
:indeterminate Applies one or more styles to radio buttons and check boxes whose toggle states cannot be determined
:lang In a document, selects the elements that are in a given language.
:last-child Applies one or more styles to the element that is the last child element of its parent element.
:link Sets the style of an A element when the link has not been visited recently.
:not Applies one or more styles to elements that do not match the simple selector.
:nth-child Applies one or more styles to the element that is the nth child of its parent element.
:nth-last-child Applies one or more styles to the element that is the nth child of its parent element, counting from the last one.
:nth-last-of-type Applies one or more styles to the element that is the nth sibling of its type, counting from the last one.
:nth-of-type Applies one or more styles to the element that is the nth sibling of its type.
:only-child Applies one or more styles to the element that is the last sibling element of its type.
:only-of-type Applies one or more styles to the element that is the only sibling element of its type.
:root Applies one or more styles to the element that is the root element of the document.
:target Applies one or more styles to the target element of of the referring Uniform Resource Identifier (URI).
:visited Sets the style of an A element when the link has been visited recently.
Pseudo-elements
::after Defines generated content that appears after an element.
::before Defines generated content that appears before an element.
:first-letter Pseudo-element Applies one or more styles to the first letter of the object.
:first-line Pseudo-element Applies one or more styles to the first line of the object.
::selection Applies one or more styles to any text on the page that the user has highlighted.
Combinators
Adjacent sibling Specifies an adjacent sibling relationship between selector elements.
Child Specifies a direct descendant relationship between selector elements.
Descendant Specifies a relationship between an ancestor selector element and a descendent element (child, grandchild, great-grandchild, and so on).
General sibling Specifies a general sibling relationship between selector elements.
See also
Concepts
Cascading style sheet reference
Understanding selectors
Properties by category
Send feedback about this topic to Microsoft. © 2011 Microsoft Corporation. All rights reserved.