Classes

Any HTML element that can go into the <body> element can have an class attribute. A CSS rule selector of the form .class-name applies to all tags whose class attribute has value class-name. A CSS rule selector of the form tag-name.class-name applies to all tag-name tags whose class attribute has value class-name.

Since the class attribute of the following paragraph is "style1", it is styled using the style rule whose selector is ".style1".

This is a paragraph styled as class "style1".

Since the class attribute of the following paragraph is "style2", it is styled using the style rule whose selector is ".style2".

This is a paragraph styled as class "style2".