0

I see code css below:

#nav .hover > a

Whats the meaning of ">" or "<" on code above ? Anyone can explain to me? Thank you.

Lena Queen
  • 741
  • 1
  • 10
  • 18

3 Answers3

4

> is called the child selector. You take all a's that are direct children of #nav .hover.

The symbol < is not allowed, as it's not to be understood as "less than" or "larger than".

poitroae
  • 20,729
  • 9
  • 59
  • 80
1

There is no < in CSS. Where as, the > is used for direct child selector.

Say, there are many elements in #nav .hover. Consider this HTML:

<div id="nav">
  <div class="hover">
    <a href="#">Direct Link</a>
    <p><a href="#">Indirect Link</a> is this.</p>
  </div>
</div>

The code #nav .hover > a will select only the Direct Link.

Where as, if you put something like #nav .hover a, it will select all the links under #nav .hover. i.e., it will select both Direct as well as Indirect Link.

Praveen Kumar Purushothaman
  • 160,666
  • 24
  • 190
  • 242
0

It selects only children of that element. In other word:

#menu li:hover > ul { display:block; }

would make the style for any <ul>s inside of that <li> (such with dropdown menus) display:block

Casey Dwayne
  • 2,122
  • 1
  • 15
  • 32