Applying Styles to Classes

If you need to apply the same style in multiple places throughout a web page, it makes sense to use the class attribute. Here are two paragraphs with a class attribute:

<p class="highlight">This paragraph has a highlight background color.</p> 
<p class="highlight">This paragraph also has a highlight background color.</p> 
<p>This paragraph does NOT have a highlight background color.</p> 

The CSS file uses a period ( . ) to reference items with class attributes, as shown below:

.highlight {
  background-color: yellow;
  }

Creative Commons License
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 2.5 License.