This is my first post to this list. Thanks to Glish, AListApart,
Listamatic, BoxLessons, ZenGarden, BlueRobot, All the amazing people
who figured out all the box model hacks and browser targeting stuff I
cannot live without. IE6 is evil. Okay...

I just stumbed onto something that I could not explain. It may be a
"feature" or "in the specification" but it had me baffled for a bit. I
did find a workaround, but I feel like I am missing something rather
fundamental to have been stumped by this seemingly basic cascade.

Consider the following HTML:

<html>
<head>
   <title>CSS Test</title>
<style>
#outer { border:4px solid red; }
#outer a { color:red; }
.inner { border:4px solid green; }
.inner a { color:green; }
</style>
</head>
<body>
<div id="outer">
    <a href="#">One</a>
    <div class="inner">
         <a href="#">Two</a>
    </div>
</div>
</body>
</html>

What color does "Two" render? If you said "Green" you're wrong.

I was expecting to get a red One link and a green Two link, but
instead One and Two are both red links.

Firebug shows the color:green crossed off, inherited #outer a... but why?

The following CSS gives the intended effect:

#outer { border:4px solid red; }
#outer  a  { color:red; }
#outer  .inner { border:4px solid green; }
#outer  .inner  a { color:green; }

Why must I specify the ID #outer in the 2nd working example?

Or, conversely, why doesn't a class' CSS override a parent container
ID's CSS? It seems like it should.

Tia,
Geoff
(FFX2, IE7, Win)
______________________________________________________________________
css-discuss [EMAIL PROTECTED]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
List policies -- http://css-discuss.org/policies.html
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/

Reply via email to