What is the CSS class selector?
The class selector selects all elements that have a given class. In CSS you write a dot before the class name.
.note { background: #fff3cd; padding: 8px; }
p.note { border-left: 4px solid orange; } /* only p elements with the class */
<p class="note">A note</p>
<div class="note important">Another note</div>
One class can be used on many elements, and one element can have many classes. An id is different: see id and class and CSS Selectors.
Learn more about the similar topics:
| Tutorials |
|---|
| CSS Selectors |
| CSS Specificity |
| CSS Pseudo-classes and Pseudo-elements |
| Exercises & Assignments |
|---|
| No Content Found. |