If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

Quick tip: Selecting by tag name

As you just learned, we use CSS rules to select elements on a web page so that we can then style those elements.
The way we tell our CSS rule which HTML elements to style is by using selectors. There are many types of selectors that we'll cover later, but here we just want to review the one we showed in the talk-through: the element selector.
The element selector selects HTML elements based on their tag names. Each HTML element—<h1>, <p>, <li>, <body>—and any other HTML element can be selected with CSS by using the tag name without the angle brackets (< and >). For example, you can select all of the <p> tags in your webpage by using the element selector p. Here's a CSS rule that changes the color of each paragraph on a web page:
p {
    color: rgb(255, 0, 0);
}
Let's check if that made sense. Which of these rules would select all of the <h2> elements on a page?
Choose 1 answer:

You'll try out using element selectors with different tag names in the next challenge. As you're experimenting, pay attention to what effect your CSS rules have on the page - which elements change color and don't.

Want to join the conversation?