CSS Selectors List

SelectorSelect
*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-linethe first line of text.
::first-letterthe first letter of text.
:beforeInserts content before.
:afterInserts content after.
:rootSelects the root element. (CSS3)
:first-childSelects the first children.
:last-childthe last children. (CSS3)
:only-childthe sole element from the containing element. (CSS3)
:only-of-typeSelects 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)
:enabledelements in their enabled state. CSS3)
:disabledelements in their disabled state. CSS3)
:checkedelements in a checked state. CSS3)
:defaultSelects default elements. CSS3)
:validSelects input elements that are valid based on input validation. (CSS3)
:invalidSelects input elements that are invalid based on input validation. (CSS3)
:in-rangeSelects constrained input elements that are within the specified range. (CSS3)
:out-of-rangeSelects constrained input elements that are outside the specified range. (CSS3)
:requiredSelects input elements based on the presence of the required attribute. (CSS3)
:optionalSelects input elements based on the presence of the required attribute. (CSS3)
:linkSelects link elements.
:visitedSelects link elements the user has visited.
:hoverelements under the mouse pointer.
:activeelements under the pointer when the mouse button is pressed.
:focusfocused element
:not(<selector>) Negates a selection.(CSS3)
:emptySelects elements that contain no child elements. (CSS3)
:lang(<language>) Selects elements based on the value of the lang attribute.
:targetSelects the element referred to by the URL fragment identifier. (CSS3)
CounterCounter
Home 
  HTML CSS Book 
    CSS Reference  

CSS Reference:
  1. Property List
  2. CSS values
  3. CSS Selectors List
Related: