Appendix C. CSS 2.1 Selectors, Pseudo-Classes, and Pseudo-Elements
This appendix contains three reference tables that can help you learn how to apply styles to the correct elements.
Table C-1 contains the CSS 2.1 selectors. Selectors help tell the browser where to apply the CSS declarations.
Note
In the “Generic pattern” column of Table C-1, the values C, R, and S take the place of type selectors.
Table C-2 contains a list of pseudo-classes. A pseudo-class is a device by which a browser applies an invisible class on its own. For example, through the pseudo-class we are able to define properties for various visited, active, and hover states of the ubiquitous link.
Table C-3 contains a list of pseudo-elements. Similar in nature to a pseudo-class, a pseudo-element places invisible tags around content in a web page and then applies styles to that element. Since the structure is more like a typical element than a class, these elements are called pseudo-elements.
| Selector | Generic pattern | Description | Sample |
Universal |
| Matches with any element |
|
Type |
| Matches any element; in this example, all |
|
Descendant |
| Matches any |
|
Child |
| Selects any |
|
Adjacent sibling |
| Selects any |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access