CSS Class
A CSS class is a reusable label you add to HTML elements with the class attribute, then target in CSS with a dot, like .button. The same class can be applied to many elements.
Web
Classes are the workhorse of CSS because they are reusable and can be combined — an element can have several classes at once. This makes them ideal for styling components consistently.
Unlike ids, which should be unique, you can use the same class on as many elements as you like.
Examples
HTML
<button class="btn primary">Save</button>Output:
Applies both the 'btn' and 'primary' class styles to the Save button.CSS
.btn {
padding: 8px 16px;
border-radius: 4px;
}Output:
Gives every element with class 'btn' padding and rounded corners.