Sometimes you only want to style some specific elements of a type instead of all elements of one type. Classes allow for a group of elements to have their own unique style. This applies to elements on the same page or on separate pages, as long as all the pages link to the same style sheet.
To style using classes:
.
before the class name. For example, the code below would style the fancy class which has been set up for a paragraph element:
HTML file | CSS File | Result |
---|---|---|
<p class="fancy">Good Day</p> |
.fancy |
W3 Schools Links
Found a bug in the documentation? Let us know at documentation@code.org