Loading...

CSS essentialsFoundations

Selectors

5 min lesson

Next

Selectors choose which HTML elements receive a set of styles. Type selectors target element names, classes target reusable groups, and IDs target a unique element.

Keep in mind

Classes are a good default for reusable styling because they can be applied to many elements.

styles.css
.notice {
  color: #183b35;
  background: #e8f3ed;
  padding: 1rem;
}

.notice strong {
  font-weight: 700;
}

What happens: Matching notice elements receive a soft background and spacing.

Previous
Next