HTML Classes
Learn how the HTML class attribute works, how to use multiple classes, and best practices with simple examples.
The class attribute is used to group multiple elements.
It allows the same styles or scripts to apply to many elements.
Class Attribute Example
<p class="highlight">First paragraph</p>
<p class="highlight">Second paragraph</p>
Multiple Classes
<div class="card featured">
Featured content
</div>
- Classes are space-separated
- One element can have many classes
Important Notes
- Class names are reusable
- Case-sensitive in CSS
- Do not start with numbers
Was this helpful?
Thanks for your feedback!