Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple tag selectors have properties under id selector

Status
Not open for further replies.

nminaker

Technical User
Jun 17, 2004
19
I'm not really sure if that makes sense, but I'll try to explain here.

I have a pair of divs that both have id selectors; links and "header" respectively. I want these two divs to not follow the rest of my css, but they have a bunch of different tags in them and it they seem to be overridden by the rest of the css.

I was trying to do this for the links id selector:
Code:
a#links {color: white;background-color:#696969;padding:0.3em 0.6em}
a:hover#links {color: #A9A9A9;}
 
Ah-ha... Alright.

So since I have a span inside the header div with the id of "intro" I could go like:

div#intro {whatever...}

to change the stuff in that span?

Also, since I have a bunch of different tags inside the divs ( ie: h2, h4, ul, li), is this how I apply the id selector properties to all of them:

#header h2, #header h4, #header ul, #header li { font-variant: small-caps; }

OR like this:

#header h2, h4, ul, li { font-variant: small-caps; }

Neither seem to give the correct look.

Thanks for your help!

Nicholas

 
1. No. To reference span, you would say #intro span { }. What you wrote would reference the div with the id of intro.

2. The first syntax is correct. The second one defines default h4, ul and li and h2 within an element with an id of header. If it doesn't work your css might be changed by another rule with higher specificity.

___________________________________________________________
[small]Do something about world cancer today: PACT[/small]
 
And about specificity, I've always found this article, CSS Spcificity Wars both funny and extremely good in describing how specificity works.

- George
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top