If #gameinfo is inside #content, then by definition anything in #gameinfo with a class of .heading is also inside #content, so yes it inherits those characteristics. You can override them any number of ways, but if the differences are substantial then personally I would just use another class. You can avoid the whole issue just by making the second class .subheading (or whatever).
-
☆ A M B ☆
- 24,524 Posts
#content .heading
#content #gameinfo .heading
would probably be the safest, as well as making it easier to see exactly what you’re working with.
Quote from: sottwell at Apr 26, 2008, 11:53 AM
#content .heading
#content #gameinfo .heading
would probably be the safest, as well as making it easier to see exactly what you’re working with.
Not only is it safer, but I have read articles stating that it’s also parsed faster by browsers...
.: COO - Commerce Guys - Community Driven Innovation :.
MODx est l'outil id
Yes. But IDs are not exclusive to DIVs, any element could have an ID.
-
☆ A M B ☆
- 24,524 Posts
Right. What that’s saying is "the element with the class of "heading" that is inside of the element with the ID of gameinfo which is inside of the element with the ID of content". So if you had #sidebar #gameinfo .heading, it would not be affected by the #content #gameinfo .heading style (unless the #sidebar container happens to be inside of the #content container...)
What you are dealing with here is "specificity"
The more specific a selector, the more preference it receives when rendering a page. Actually, there are rules for calculating an item’s specificity. Basically, numeric values are assigned to certain CSS selectors. Every id selector has a value of 100; class selectors have a value of 10 and every HTML selector is assigned a value of 1. You add up these values for CSS rules and the higher number wins. The following calculations are made on the previous example:
* BODY H1 consists of two HTML selectors, so it is 1 + 1 = 2.
* H1 consists of one HTML selector, so the result is 1.
* In every instance, 2 > 1, so H1 elements (within BODY elements) are red.
http://articles.techrepublic.com.com/5100-3513-6164216.html
http://www.w3.org/TR/REC-CSS2/cascade.html