How to select HTML elements tags directly inside CSS?

To select an HTML element tag directly inside the CSS stylesheet, you can use the name of the HTML element tag directly in the CSS. These selectors are also called type selectors in CSS.

For example, consider 2 p (paragragh) tags in HTML like this,

<!-- Paragragh tags-->
<p>Hello World!</p>
<p>Hello Devs</p>

Now in the CSS stylesheet, we can select the p HTML tags by wrting the name of the HTML tag in the CSS like this,

/* Select p tags from HTML */
p {
  /* Your styles */
}

Like this, you can select any valid HTML element tags.

Now, Let's set the color of all the text in the p tags to red like this,

/* Select p tags from HTML */
p {
  color: red;
}

This rule will set all the p HTML tags text to have the color red.

The output will look like this,

See the above code live in JSBin.

That's all πŸ˜ƒ!

Feel free to share if you found this useful πŸ˜ƒ.

24