CSS Selectors List
Selector | Select |
---|---|
* | all elements. |
<type> | elements of the specified type. |
.<class> | elements of the specified class. |
#<id> | elements for the id attribute. |
[attr] | elements that define the attribute attr, regardless the attribute's value. |
[attr="val"] | elements with attr whose is val. |
[attr^="val"] | elements with attr whose value starts with the string val. (CSS3) |
[attr$="val"] | elements with attr whose value ends with the string val. (CSS3) |
[attr*="val"] | elements with attr whose value contains the string val. (CSS3) |
[attr~="val"] | elements with attr whose value contains multiple values, onc of which is val. |
[attr|="val"] | elements with attr whose value is a hyphen-separated, the first is val. |
<selector>, <selector> | the union of the elements matched by each individual selector. |
<selector><selector> | Selects elements that match the second selector and that are arbitrary descendants of first selector. |
<selector>><selector> | Selects elements that match the second selector and that are immediate descendants of the first selector. |
<selector> + <selector> | Selects elements that match the second selector and that immediately follow the first selector. |
<selector> ~ <selector> | Selects elements that match the second selector and that follow an element that matches the first selector. (CSS3) |
::first-line | the first line of text. |
::first-letter | the first letter of text. |
:before | Inserts content before. |
:after | Inserts content after. |
:root | Selects the root element. (CSS3) |
:first-child | Selects the first children. |
:last-child | the last children. (CSS3) |
:only-child | the sole element from the containing element. (CSS3) |
:only-of-type | Selects elements that are the sole element of their type defined by their containing element. (CSS3) |
:nth-child(n) | the nth child of their parent. (CSS3) |
:nth-last-child(n) | the nth from last child of their parent. (CSS3) |
:nth-of-type(n) | the nth child of their type defined by their parent. (CSS3) |
:nth-last-of-type(n) | the nth from last child of their type defined by their parent. (CSS3) |
:enabled | elements in their enabled state. CSS3) |
:disabled | elements in their disabled state. CSS3) |
:checked | elements in a checked state. CSS3) |
:default | Selects default elements. CSS3) |
:valid | Selects input elements that are valid based on input validation. (CSS3) |
:invalid | Selects input elements that are invalid based on input validation. (CSS3) |
:in-range | Selects constrained input elements that are within the specified range. (CSS3) |
:out-of-range | Selects constrained input elements that are outside the specified range. (CSS3) |
:required | Selects input elements based on the presence of the required attribute. (CSS3) |
:optional | Selects input elements based on the presence of the required attribute. (CSS3) |
:link | Selects link elements. |
:visited | Selects link elements the user has visited. |
:hover | elements under the mouse pointer. |
:active | elements under the pointer when the mouse button is pressed. |
:focus | focused element |
:not(<selector>) | Negates a selection.(CSS3) |
:empty | Selects elements that contain no child elements. (CSS3) |
:lang(<language>) | Selects elements based on the value of the lang attribute. |
:target | Selects the element referred to by the URL fragment identifier. (CSS3) |
Counter | Counter |