CSS is the language we use to style an HTML document.
CSS describes how HTML elements should be displayed.

Classes and IDs are used as hooks for CSS styles. While the way CSS renders is not affected by the use of classes and hooks, they give developers the ability to pinpoint HTML elements that they wish to style.

When to Use Classes

Use classes when there are multiple elements on a single web page that need to be styled.

.myparagraph { color:red; font-size: 20px; } 
<body> 
<p class="myparagraph">hello world</p> 
</body>

When to Use IDs

Use IDs for elements that only appear once on a web page.

#myparagraph { color:red; font-size: 20px; }

<body> 
<p id="myparagraph">hello world</p>

</body>

or do example in https://www.w3schools.com/css/default.asp

Share this Article !

You may like this