A class selector matches every HTML element carrying a specified class value. Add the class with the class attribute, then reuse one CSS rule across as many elements as needed. section 1.6.1
Use class selectors effectively by following these practical rules:
- Separate multiple class values in the class attribute with spaces, allowing one element to receive several reusable style groups. section 1.6.1
- Choose names that describe the element or role clearly; avoid vague names such as text or names tied to a temporary color. section 1.6.1
- Remember that class selectors contribute a specificity value of 10, exceeding type selectors but falling below ID selectors. section 1.5
Styling both sides of a credit card
A virtual credit card uses the shared class card-item__side on its front and back. A rule for that class handles common styling, while .front and .back add side-specific styles. This combination keeps shared declarations together without losing control of each side. section 9.2
View the figure showing a class selector applied to elements carrying the small-heading class. section 1.6.1

