Easy points here for anyone who knows. I am looking for a detailed answer on what it (>
) means and how it should be used. Thanks.
Asked
Active
Viewed 706 times
7
-
are you looking for http://stackoverflow.com/questions/1628485/what-does-in-css-mean?rq=1 – N30 Jul 03 '12 at 14:31
3 Answers
4
There is no valid symbol as <
in CSS. If you use it, you will invalidate your css.
However, you may want to use >
- the child selector.
CSS4 will introduce a subject selector. At the moment it is marked with $
.
so
$#parent a:hover{
/* styles */
}
so these rules will not apply to the a in hoverstate, but it's parent with the parent
-ID. CSS4 spec
-
I thank you for your correction, the detailed description, and the nod to the future. – bkbarton Jul 03 '12 at 14:52
1
You may be thinking of the >
(great than symbol) selector.
This selector is known as the child combinator selector.
This means it will only select direct children of the parent. For example:
ul > li
So for example, if you wanted to style a nested unordered list as such:
<ul>
<li></li>
<li>
<ul>
</ul>
</li>
</ul>
You would have to style it as such:
ul > li > ul
But this is only in the case of using >
, child combinator selector.

Christoph
- 50,121
- 21
- 99
- 128

Aaron Brewer
- 3,567
- 18
- 48
- 78
-
`ul ul` would also catch that particular case… we could add a `ul` inside the `li` to make it more relevant, though I'm not actually sure what putting a `ul` directly inside a `ul` would do. – Matchu Jul 03 '12 at 14:39
-
@Matchu: I never place a ul inside a li, if I am going to nest a ul, I make sure I put it within the ul, not the li. It have the exact same results, it just makes your HTML look cleaner and more readable. – Aaron Brewer Jul 03 '12 at 14:41
-
Sorry, but I don't see non-validating HTML as "cleaner" than validating HTML. – Mr Lister Jul 03 '12 at 14:43
-
@MrLister: Regardless of the validity of the HTML in my "example", my answer to the question above is correct and I do not see why you would be concentrating on the validity of nesting an unordered list instead of answering the users question. – Aaron Brewer Jul 03 '12 at 14:46
-
@AaronBrewer how you write it, it's creates invalid markup. Very dangerous since you can't rely on consistent rendering. – Christoph Jul 03 '12 at 14:47
-
-
-
-