CSS Class Selectors

In an HTML document, CSS Class selectors match an element based on the contents of the element's  attribute. The  attribute is defined as a space-separated list of items, and one of those items must match exactly the class name given in the selector. The selector is written by first using the node name of the element, followed by a period, then the name of the. Example:. It can also be written simply by stating the  name, without having to have it match an exact element. Example:.

Example:

Title  span.class1 { background: blue; }

span { background: red; }

.other { color: green; }   This text has a blue bg. This one has a red one. This one has green text. This one has a blue bg with green text.