A class is an attribute that you can assign to HTML elements to group them together. Classes allow you to apply the same styles to multiple elements and can also be used for JavaScript manipulation.
You can define a class in your HTML by adding the class
attribute to an element:
<div class="example">This is a div with a class.</div>
In your CSS, you can style the class by using a dot (.) followed by the class name:
.example { background-color: lightblue; }
Here are multiple paragraphs styled with the same class:
This paragraph is highlighted.
This paragraph is also highlighted.
And this one is highlighted too!
This text is centered using a class.
This text is not centered.
This paragraph is both highlighted and centered!