Element Selector-Introduction to CSS [CSS3 compatible]

The element selector is for specifying the tag name of the element.

The element selector is the same as the tag name.

span {
  color: red;
}

Let's use the element selector.

tomato

<style>
  span {
    color: red;
  }
</style>

<span> tomato </span>

Combination of class selector and element selector

You can also combine class selectors with element selectors.

  • tomato
  • Lettuce
<style>
  li.active {
    color: red;
  }
</style>

<ul>
  <li class = "active"> tomato </li>
  <li> Lettuce </li>
</ul>

Associated Information