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] | Applies to an element of type E with an "attr" attribute. | |||||
| E[attr="val"] | Applies to an element of type E with an "attr" attribute equal to "val". | |||||
| E[attr*="val"] | 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"] | 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"] | 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"] | Applies to an element of type E with an "attr" attribute and whose value begins exactly with "val". | |||||
| E[attr$="val"] | 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 | Applies to an F element which is a direct child of an E element. | |||||
| E + F | Applies to an F element which is immediately preceded by an E element. | |||||
| E ~ F | Applies to an F element which is a preceded by an E element. | |||||
| Pseudo elements | ||||||
| ::after | Can be used to specify generated content after an element's contents. | |||||
| ::before | 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 | Applies to elements that doesn't have any content. | |||||
| :first-child | Applies to the first child of an element. | |||||
| :first-of-type | Applies to an element's first child of its type. | |||||
| :last-child | Applies to the last child of an element. | |||||
| :last-of-type | Applies to an element's last child of its type. | |||||
| :nth-child () | Applies to element which is the n-th child of its parent. | |||||
| :nth-last-child () | Applies to element which is the n-th child of its parent, counting from the last one. | |||||
| :nth-of-type () | Applies to element which is the n-th sibling of its type. | |||||
| :nth-last-of-type () | Applies to element which is the n-th sibling of its type, counting from the last one. | |||||
| :only-child | Applies to element which is the only child of its parent. | |||||
| :only-of-type | Applies to element which is the only sibling of its type. | |||||
| :root | 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 | Applies to element which being the target of the referring URI. | |||||
| Dynamic pseudo-classes | ||||||
| :active | Applies to the currently engaged or active element within the document. | |||||
| :focus | Applies to the currently focused element. | |||||
| :hover | Applies to the element whereon the mouse pointer is currently over. | |||||
| State pseudo-classes | ||||||
| :enabled | Applies to standard user interface elements that are enabled to use by the user. | |||||
| :disabled | Applies to standard user interface elements that are disabled. | |||||
| :checked | Applies to element which is in checked state. | |||||
| :indeterminate | Applies to element which is in indeterminate state. | |||||
| :default | Applies to default user interface elements. | |||||
| Language pseudo-class | ||||||
| :lang | Applies to elements with the specified language setting. | |||||
| Negation pseudo-class | ||||||
| :not() | Used to negate a normal selector. | |||||
User Contributed Comments

