Child Selector ("parent > child")

Selects all direct child elements specified by "child" of elements specified by "parent".

.child(parent, child)

parent SelectorAny valid selector.
child SelectorA selector to filter the child elements.

The child combinator (E > F) can be thought of as a more specific form of the descendant combinator (E F) in that it selects only first-level descendants.

Places a border around all list items that are children of <ul class="topnav"> .

JS
<ul class="topnav">
  <li>Item 1</li>
  <li>
    Item 2
    <ul>
      <li>Nested item 1</li>
      <li>Nested item 2</li>
      <li>Nested item 3</li>
    </ul>
  </li>
  <li>Item 3</li>
</ul>
CSS
body {
  font-size: 14px;
}
HTML
$("ul.topnav > li").css("border", "3px double red");
DEMO

Looking for a Web Developer?

👋

Hi! I'm Basti, author of this site. If you are looking for a web developer with 15+ years of experience, holla at me!

Be it the good 'ol jQuery, vanilla JS or modern frameworks like Vue and Svelte, front- or backend, I can help you.

Just write me at jobs@jqapi.com :)