Labs ICT
Pro Login

Element Selector

The simplest way to target elements in CSS is by their HTML tag name. This is called the element selector (or type selector).

You write the tag name without the angle brackets, then your styles in curly braces.

p {
  color: #333;
  font-size: 16px;
}

h1 {
  color: darkblue;
  text-align: center;
}

div {
  background-color: #f5f5f5;
  padding: 20px;
}

This targets every p, h1, and div on the page. No extra markup needed. Just pick the tag and style it.

Try it Yourself →

When to Use Element Selectors

Element selectors are great for setting base styles. For example, you might want all your paragraphs to use the same font size and line height, or all your links to be a specific color. Instead of adding a class to every paragraph, just use the p selector and be done with it.

The downside? It applies to every element of that type. If you need different styles for different paragraphs, you will need classes or IDs.