Hello
Suppose we want to find out what will be the color property of particular <h2>
element.
1) When trying to figure out how specific a selector is, one of the rules says that selector with greater number of classes is more specific than selector with fewer classes. Thus, in the following example the color of particular <h2>
should be green ( this example is taken from some web site ):
.one .two .three .four .five .six .seven
{
color: green;
}
.eight .nine .ten
{
color: blue;
}
a) First of all, if I specify more than one class in a selector, then it doesn’t work…in other words, text won’t be either green or blue. Any idea why it doesn't work?
b) Ignoring the fact that selector won’t work if it contains more than one class:
Are classes .two .three .four .five .six .seven descendants of class .one or is our particular <h2>
element a member of all those classes?
2) Another rule says that if we selector with greater number of IDs is more specific than selector with fewer IDs. So in the following example the color of particular <h2>
should be green:
#one #two # three #four #five #six #seven
{
color: green;
}
#eight #nine #ten
{
color: blue;
}
a) The above claim makes sense only if #two is a child of one#, #three a child of #two and a grandchild of #one etc?! Correct?
3) I assume more specific selector defined in user’s css file is chosen over less specific selector defined in author’s css file?
thanx
EDIT:
The first CSS rule applies to all elements with the class of "seven", which have an ancester with the class of "six", which in turn have an ancestor with the class "five" and so on.
Uhm, you mean the rule applies to an element E7, but only if : - E7 is member of class .seven and descendant of element E6 - E6 is member of class .six and descendant of element E5 - E5 is member of class .5 and descendant of element E4 etc ?
May I also ask if my assumption about my second question ( in initial post ) is correct?