Code highlights logo



Type selectors

The Type Selector selects HTML elements based on their tag name. For example, if you want to select all the paragraphs on the page, you can use the Type Selector p.

Here's an example of how to use the Type Selector to set the color of all the paragraphs to red:

1p {
2 color: red;



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


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

1color: green;

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

Sign up to start coding

Already have an account?

Sign In

Course content