Basic selectors
suggest changeSelector | Description |
———————–– | ———– |\*
| Universal selector (all elements) |div
| Tag selector (all <div>
elements) |.blue
| Class selector (all elements with class blue
) |.blue.red
| 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.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents