Geoffrey Hoffman schrieb:
> 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/
>
Hello,
you might consider looking at this page:
http://www.w3.org/TR/REC-CSS2/cascade.html#specificity
The id selector is a higher specifity and the rule attached to it is
therefore chosen in the 1st example.
Regards,
Christian
*Directmedia Publishing GmbH* · Möckernstraße 68 · 10965 Berlin
www.digitale-bibliothek.de
AG Berlin-Charlottenburg · HR B 58002 · USt.Id. DE173211737
Geschäftsführer: Ralf Szymanski · Erwin Jurschitza
______________________________________________________________________
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/