Basic selectors

suggest change

Selector | Description | ———————–– | ———– |\* | Universal selector (all elements) |div | Tag selector (all <div> elements) |.blue | Class selector (all elements with class blue) | | All elements with class blue and red (a type of Compound selector) |#headline | ID selector (the element with “id” attribute set to headline) |:pseudo-class | All elements with pseudo-class |::pseudo-element | Element that matches pseudo-element |:lang(en) | Element that matches :lang declaration, for example <span lang="en"> |

|div > p | child selector |

Note: The value of an ID must be unique in a web page. It is a violation of the HTML standard to use the value of an ID more than once in the same document tree.

A complete list of selectors can be found in the CSS Selectors Level 3 specification.

Feedback about page:

Optional: your email if you want me to get back to you:

Table Of Contents