child selectors

1st Apr 2004

I found this nice explanation of child selectors on the css-discuss forum:

What does it mean when there's a ">" in the css code? For example:li.sub > aIt's a "child selector"li.sub > a will select all anchors that are children of the list item with class .sub. However, it will not select those anchors in this list item which are nested inside some element. Example:<li class="sub"><a href="">doepud</a><div><a ref="">doepud</a></div></li>In this example, only the first anchor will be selected by your child selector, not the second one. To select both, one might use:li.sub awhich is a descendant selector, where the depth of nesting doesn't matter.