CSS class selector
Class selectors find elements with the specific class set by the HTML class attribute. A class selector is preceded by a full stop (.
). For example, the selector for all elements of the class center would look like this: .center
.
The class selector is the most commonly used selector type because of its flexibility — you can add the same class to different elements or multiple classes to one element.
Combining element type selectors with class selectors allows you to target elements of a specific type with a certain class. For example, to select all <h1>
headings with the class center, use the selector h1.center
.