Class selectors match elements based on the contents of an element’s class attribute. The class selector .author, for example, would match any HTML element with the class attribute of “author.” The specific nature of class selectors combined with the ability to apply class attributes to any element makes them an extremely powerful and flexible option for styling. Because they are so easy to use class selectors can occasionally be over-used, resulting in non-semantic code and code that is more difficult to maintain.
Syntax
Class selectors are written by adding a period (‘.’) prior to the contents of the targeted attribute value, with no whitespace between the two. To make a class selector specific to an element type, add the element type prior to the period with no whitespace. The selector p.summary would match any paragraph with the class attribute of “summary”. Although CSS is not case-sensitive, there are certain use-cases where the styled document may parse classes with case sensitivity. Because of this it’s a good practice to match the case of class values.