i don’t understand the classes and id.

What do you not understand? Is there something specific or just classes and id in general?

i want to understand only classes and id. i don’t know how to create class. and how can we give a name to class.

So firstly this is a CSS class syntax.

.class {
    css declarations;

Here is a example. With this css class:

.main {
    background-color: yellow;

All elements with class="main" will have a background color of yellow. Class is used if you want to style lots of elements. ID is used when you want to style a specific element.

Here is ID syntax

#firstname { 
    background-color: yellow;

As you have most likely realised, all elements with id="firstname" will have a background color of yellow.
The biggest difference between class and id is the full stop and the hashtag. A full stop defines a class and a hashtag defines a ID.

I hope this has cleared it up, let me know if you need further explanation.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.