Tag, class, and id selectors

A tag selector targets every element with that tag name. A class selector starts with a dot and can be reused. An id selector starts with a hash and should identify one unique element on a page.

p {
  color: #333;
}

.card {
  padding: 1rem;
}

#page-title {
  color: teal;
}

In HTML, add a class or id with an attribute, such as <article class="card">.

Learn more