Direct Selector | |
---|---|
Selector | Meaning |
tagName | All the tags |
[tag].className | All the tags with a specific class |
[tag]#id | The tag with a specific ID |
* | Any element |
Context Selector | |
Selector | Meaning |
E F | Select element F that is a descendent of E |
E > F | Select element F that is a direct child of E |
E + F | Select element F that is an immediate sibling after E |
E ~ F | Select element F that is a sibling after E |
Pseudo Element Selector | |
Selector | Meaning |
::first-letter | The first letter in text |
::first-line | The first line of text |
::before | The space immediately before the element (used with content property) |
::after | The space immediately after the element (used with content property) |
Link and Dynamic Pseudo Class Selector | |
Selector | Meaning |
:link | The hyperlink when it first appears (used with a hyperlink tag) |
:visted | The hyperlink that has been clicked (used with a hyperlink tag) |
:target | A targeted anchor link (used with an anchor tag) |
:hover | The element that is under the cursor |
:active | The element that is being clicked |
:focus | The element that has the focus |
:enabled and :disabled | The element that is enabled or disabled |
:checked | The element that is checked (used with a radio button or a checkbox) |
Structural Pseudo Class Selector | |
Selector | Meaning |
:root | The top level element of the document |
:empty | The element that has no child |
:only-child | The element that has no siblings |
:first-child | The first child of some other element |
:last-child | The last child of some other element |
:nth-child(an + b) | The (an + b)-th child within its parent element. The index of the first child is 1. The use of a and b is:
|
:nth-last-child(an + b) | The (an + b)-th last child within its parent element |
:only-of-type | The element that has no sibling of the same type |
:first-of-type | The first of its selector type within its parent element |
:last-of-type | The last of its selector type within its parent element |
:nth-of-type(<an + b) | The (an + b)-th of its selector type within its parent element |
:nth-last-of-type(an + b) | The (an + b)-th of its last selector type within its parent element |
Other Pseudo Class Selector | |
Selector | Meaning |
:lang(l) | The element that has a specific language code l defined |
:not(s) | Not confirming to selector s |
Attribute Selector | |
Selector | Meaning |
[attr] | The element that has a specific attribute |
[attr = "value"] | The element that has a specific attribute with an exact value |
[attr ~= "value"] | The element that has a specific attribute with an exact value in a space-seprated value list |
[attr |= "value"] | The element that has a specific attribute with an exact value in a hyphen-seprated value list |
[attr ^= "value"] | The element that has a specific attribute with an exact pattern at the beginning of the value |
[attr $= "value"] | The element that has a specific attribute with an exact pattern at the end of the value |
[attr *= "value"] | The element that has a specific attribute with an exact pattern anywhere in the value |