3. Selectors

You use selectors to define the elements on a page that you want to apply certain properties to. Elements in the document can be matched based on the HTML tag used, based on class or ID attributes, based on the relationship to other elements, or based on the current status in the document. You can also combine simple selectors to form a chain of conditions that must be met before the style rule is applied.

E (Type Selectors)

The type selector selects an element by its type.

h1 {} /* selects all h1 elements */form {} /* selects all form elements */

* (Universal Selector)

The universal selector matches any element type in the document. It is implied if there is a sequence of other simple selectors and no specific type selector is ...

Get The CSS Pocket Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.