Jump to content

Nesting multiple selectors behind id or class


jay_m

Recommended Posts

Very simple question. Is it possible to put multiple html selectors behind a CSS id or class selectors?Ex.

#main p, h1, h2, h3, h4, a, li {  color:#ffffff;}

So I would want the html tags to use the color: #ffffff; if they were in a div tag id'd with #main. I have seen stylesheets setup like this but have not gotten them to work properly for me. Can I setup this type of nesting and how is it properly applied? Thanks,

Link to comment
Share on other sites

if you had #main p, h1, h2, h3, h4, a, li { color:#ffffff;}p, h1, h2, h3, h4, a, li { color:#000000;}all p, h1, h2, h3, h4, a, and li would have black text Except p tag in parent element with id main which will remain white, as any element with parent id ref will have higher styling precedence over selectors that are without. To change colour of text to white for rest of h1, h2, h3, h4, a, and li within parent #main element you would add prefix of #main #main p, #main h1, #main h2, #main h3, #main h4, #main a, #main li { color:#ffffff;}

Link to comment
Share on other sites

Just to point out if you had it the other way round p, h1, h2, h3, h4, a, li {color:#000000;} #main p, h1, h2, h3, h4, a, li {color:#ffffff;}All h1, h2, h3, h4, a, li would have WHITE text, except any p tag outside of #main parent element which would remain black

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...