SyntaxStudy
Sign Up
HTML Styling with CSS Classes
HTML Beginner 3 min read

Styling with CSS Classes

CSS Classes

CSS classes target multiple elements sharing the same name. Add a class with class="name" and select it in CSS with .name.

Classes are the cornerstone of reusable, maintainable CSS.

Example
<!-- HTML -->
<p class="highlight">Important paragraph</p>
<span class="highlight">Also highlighted</span>

/* CSS */
.highlight {
  background: yellow;
  font-weight: bold;
}
Pro Tip

Name classes by purpose (e.g. .btn-primary) not by appearance (e.g. .blue-button).