Jump to content

Universal selector


smus

Recommended Posts

Is it possible to apply to several tags with one selector, not creating class for it? For example, I want a common property for all headings in the document:

h1, h2, h3{color: orange;}

<h1>h1</h1>

<h2>h2</h2>

<h3>h3</h3>

Something like h^{color: orange;} for tag selectors?

 

Link to comment
Share on other sites

:) naive solution, because, hypothetically, headings might be scattered around the document.

No, I was just wondering why developers invented such convenient thing, but did not apply it to tag names. Philosophical question :)

Link to comment
Share on other sites

  • 8 months later...

If you have only header tags in your HTML than you can use * as an universal selector. Or else you can give names if there are only few tags as you don`t want to give class to the all elements.

Link to comment
Share on other sites

  • 4 months later...
  • 2 weeks later...

Hello @smus,
Simply you can use the element name separated by a comma as a selector in CSS. Following is the example of multiple tags as a single selector.

E.x.
h1, h2, h3 {
        color:orange;
}

Edited by ishan_shah
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...