
Originally Posted by
etidd
Is the following
Code:
ul.pMenu ul li ul li ul
different from:
Yes, those are the same, assuming that each sub UL is nested inside a LI, as it should be.
How does using the > symbol make CSS selections different? For example,
Code:
ul.pMenu ul ul ul > li
The > symbol means that the rule is only applied to a LI that is the direct child of the last UL. So that rule would be the same as this:
Code:
ul.pMenu ul ul ul li
So you use > if you only want the rule to apply to the direct child of the UL, and not any LIs that might be further nested below.
Another example might be:
Code:
ul.pMenu > li {color: red}
If that were applied to a structure like
Code:
<ul class=pMenu">
<li>
<ul>
<li>
</li>
</ul>
</li>
</ul>
only the top-level LI would be red, whereas with this rule
Code:
ul.pMenu li {color: red}
all of the LIs would be red:
Code:
<ul class=pMenu">
<li>
<ul>
<li>
</li>
</ul>
</li>
</ul>
Bookmarks