CSS Class Selector

In this tutorial you will learn about the CSS Class Selector and its application with practical example.

CSS Class Selector

CSS classes are set of styling rules that can be applied or assigned to the HTML entity using it’s class attribute and all the HTML elements having that class assigned will be assigned the styling as per the definition of the defined CSS class.

Syntax

The syntax for declaring a Class selector is as:

Example:

To apply this style to the HTML, using the following code:

If you want to use the same class name for different selector , but each with a different styling behavior as per their selector. This is achieved by using the or prefix the dot with the HTML Selector name.

Example:

For example, if we have the following CSS declaration:

Both the special class have the different behavior based on their selector.

Applying Multiple CSS Classes

It is possible to assign multiple classes at the same time for the class attribute of the HTML Entity and the classes will apply their styling to the element.

Example:

The above classes can be applied as follows:

 

 

In this tutorial we have learn about the CSS Class Selector and its application with practical example. I hope you will like this tutorial.