HTML: Creating Classes and IDs

There will be times when you want to use CSS to style multiple HTML tag elements at once.

For example, imagine you wanted to select most – but not all – of the <p> tags inside your HTML document at once because you wanted those specific paragraphs you selected to be of the same font size and colour. How can you do this?

You can group such tag elements inside your HTML document by using either of two attributes: IDs or classes. You can then use the respective “ID” or “class” value you assigned in CSS to edit all the respective IDs or class elements at once.

“IDs” are used to identify a unique group of tag elements which can only use one single value in your whole HTML document. A “class”, on the other hand, can be the same value you assigned repetitively throughout your HTML document so that more than one group of tags elements fall under the same “class” name.

 

write12Example

<body>
<section id=”choc curry”>
<h1>Chocolate Curry</h1>
<p class=”intro”>This is the recipe</p>
<p class=”intro”>Read below to learn how to do a Chocolate Curry</p>
</section>
</body>