Learn

Remember that declarations are a fundamental part of CSS because they apply a style to a selected element. But how do you decide which elements will get the style? With a selector.

A selector is used to target the specific HTML element(s) to be styled by the declaration. One selector you may already be familiar with is the type selector. Just like its name suggests, the type selector matches the type of the element in the HTML document.

In the previous lesson, you changed the color of a paragraph element.

p { color: green; }

This is an instance of using the type selector! The element type is p, which comes from the HTML <p> tag.

Some important notes on the type selector:

  • The type selector does not include the angle brackets.
  • Since element types are often referred to by their opening tag name, the type selector is sometimes referred to as the tag name or element selector.

Instructions

1.

Open style.css. On line 5, add a ruleset using the type selector to target all <h1> elements. Leave the declaration block ({ }) empty for now.

2.

Inside the curly braces of the h1 selector, add the declaration below:

color: maroon;

Note that the content of the web page will update because we’ve already linked style.css to index.html.

Take this course for free

By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.
Already have an account?