Let's pretend I have multiple HTML <div> elements on a page:
<div id="box1">Box 1</div>
<div id="box2">Box 2</div>
<div id="box3">Box 3</div>
and I want all of them to have red text.
To apply the same style to all of them, I can use a CSS class. A class is specified with a period . character before the name of the class:
.myredtext
{
color: red;
}
After adding the class to my CSS file, I then add the class to each <div> element:
<div id="box1" class="myredtext">Box 1</div>
<div id="box2" class="myredtext">Box 2</div>
<div id="box3" class="myredtext">Box 3</div>
Leave a comment