On Dec 19, 2007 12:50 PM, Rob S <[EMAIL PROTECTED]> wrote: > > On 12/19/07, Ian Wienand <[EMAIL PROTECTED]> wrote: > > > > Hi, > > > > Can someone explain to me why the HTML/CSS below seems to allow some > > attributes of the H1 within the class to change, but not others? > > > Hi, > > It's a precedence issue - div#maindiv h1 is being applied after div.aclassh1. > If you remove the color attribute from div#maindiv h1 you'll see that > the first header is black, and the second blue. >
Hi, I think the first rule takes precedence because ids are considered more specific than classes, and I don't think that CSS cares how your elements are actually nested. You could fix this by: 1. Changing the selector on the second rule to #maindiv .aclass h1. This makes the rule more specific, thus giving it higher precedence. 2. Adding !important onto the end of the color attribute. This overrides precedence for a particular attribute within a rule. -Michael
_______________________________________________ coders mailing list coders@slug.org.au http://lists.slug.org.au/listinfo/coders