Confusion about two different CSS syntax to select nested elements

css, css-selectors

Solution

No, they are not equivalent. The first one is the descendant selector, while the second is the child selector.

Quick example:

<div class="a">
  <div class="b">
    <div class="c"></div>
  </div>
</div>

With this markup `.a > .c` will select nothing, while `.a .c` and `.a > .b > .c` will select the innermost element.

Problem

Possible Duplicate: What does “>” mean in CSS rules? CSS has the following two syntaxes which seem to be doing the same thing. Selecting a nested element. ``` div span div > span ``` Am I missing something, or are these two indeed equivalent selectors ?

Original source

Related problems