Jump to content
smus

Universal selector

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?

 

Share this post


Link to post
Share on other sites

There is only 6?, you don't have apply a class  to all, just the parent
 

<div class="myheadercolor">

<h1>h1</h1>

<h2>h2</h2>

<h3>h3</h3>

</div>
.myheadercolor h1, .myheadercolor h2,.myheadercolor h3 {color: orange;}

 

Share this post


Link to post
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 :)

Share this post


Link to post
Share on other sites

As they are part of the same document, representing main title heading and sub headings of importance, No! not really, as they, would come under the same parent element. IF they were scattered anywhere, then they are not used as they were properly intended.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...