. . .

How to write a class in css?

Using classes is simple. You just need to add an extension to the typical CSS code and make sure you specify this extension in your HTML. Let’s try this with an example of making two paragraphs that behave differently. First, we begin with the CSS code, note the red text.

CSS Code:

p.first{ color: blue; }
p.second{ color: red; }

HTML Code:

<p>This is a normal paragraph.</p>
<p class="first">This is a paragraph that uses the p.first CSS code!</p>
<p class="second">This is a paragraph that uses the p.second CSS code!</p>
Please share the article
Posted in CSS

Leave a Reply

Your email address will not be published. Required fields are marked *

13 + 1 =