CHAPTER 3

image

Class and id selectors

Class and id selectors define rules that apply to only a selected set of HTML elements. They allow you to identify individual elements, or groups of elements, without having to style all instances of the element type.

Class selector

The class selector is used to identify a group of elements. It is recognized by the period sign (.), followed by a class name. The class can be a general class that can be applied to any element.

/* Selects any element with class name myclass */.myclass {}

The selector can also be a specific class that can be applied to only one type of element. The specific class is defined by declaring ...

Get CSS Quick Syntax Reference 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.