How To Use class Selector?

The class selector selects a group of elements. If we want to apply styles to a group of elements we should use class selector.

The class selector uses the HTML class attribute, and is defined with a ".".

 

In the example below, all HTML elements with class="center" will be center-aligned:

 

.center {text-align:center;}

Let's put the class selector to work.

 

 

 

 

     

         

     

     

        Visit the website 

        Visit the website 

        Visit the website 

     



In the code above we create a style with class selector. Then we use it with two paragraph tags and one heading tag. We can use the same style for different tags.