April 2018
Beginner
368 pages
7h 37m
English
We saw how to select HTML tags with CSS, but, most of the time, you'll have multiple identical HTML tags, such as <p> or <a>. How do we differentiate them so we can only select and style a specific one? Here come the classes and IDs. They're used to select a specific HTML tag you have put an attribute id or class, for example:
<div id="header"></div><p class="big"></p>
To select this ID header in CSS, we'll need to write a hash (#) character, followed by the ID of the element, in this case, header:
#header { margin-left: 10px;}
To select a class, we'll need to write a period (.) character, followed by the name of the class:
.big { font-size:20px;}
So what is the difference between IDs and classes? The only difference is that ...