Forum Moderators: not2easy

Message Too Old, No Replies

How to apply style rules to a containing div?

         

jamesw

8:34 am on Jan 16, 2009 (gmt 0)

10+ Year Member



In my HTML doc I want to say
<div id="public-forms">
<h2>My public form</h2>
<h4>My section</h4>
... lots of html
</div>

In another html doc for the same site I want to say
<div id="admin-forms">
<h2>My admin form</h2>
<h4>My section</h4>
</div>

I don't want to have to apply a style to each individual element I just want to apply different styling rules deepending on the containing div

Now in my css I want to be able to style h1,h2,h3,h3 with something like

#public-forms, h1, h2, h3, h4 {
background-color: #ffffc0;
}

#admin-forms, h1, h2, h3, h4 {
background-color: #efe;
}

So that all h1 to h4 elements that appear inside a div are given a specific background colour.

Now what I am doing above does colour the background for the h elements but they all have the same colour applied.
i.e. all h1 elements take on the background colour for the admin forms selector.

Any pointers as to how I should be doing this would be greratly appreciated.

Thanks

James

tomda

10:55 am on Jan 16, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



#public-forms h1, #public-forms h2, #public-forms h3, #public-forms h4 {
background-color: #ffffc0;
}

#admin-forms h1, #admin-forms h2, #admin-forms h3, #admin-forms h4 {
background-color: #efe;
}

jamesw

1:25 pm on Jan 16, 2009 (gmt 0)

10+ Year Member



Utterly superb.
Such simple things have been driving me nuts and I now understand a whole lot more fron that reply.

Thank you

James