The child combinatorparent > child (since jQuery 1.0) selects only direct children of a parent. It is a more specific form of the descendant combinator (parent child), which matches at any nesting depth. Official docs call it a standard CSS combinator.
Syntax
Start with these common calls. Keep them short and readable.
jQuery
$("ul.topnav > li") // direct li only
$("ul.topnav li") // every li inside (any depth)
$("div > span") // spans that are immediate children
$("nav > ul > li > a") // chain one level at a time
// Equivalent traversal: $(parent).children(child)
Call
What it does
parent
Any valid selector for the parent elements
>
Child combinator (direct children only)
child
Filter applied to each parent’s immediate children
Return value
jQuery collection of matching child elements
Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.
Parameters
Parameter
Description
Step 1
Write a parent selector (id, class, or tag) on the left of >.
Step 2
Write a child selector on the right — only matching immediate children are kept.
Step 3
Chain more > steps when you need a fixed depth (e.g. nav > ul > li > a).
Return Value
Return Value
Description
jQuery object
Most setters and traversing helpers return the jQuery collection so you can chain more methods.
Value / undefined
Getters usually return a value from the first matched element, or undefined when nothing applies.
jQuery Examples
Example 1 — Official ul.topnav > li
Mark only top-level list items — nested sub-list items are skipped.
Combinator.> keeps only that ul’s immediate li children.
Skip. Nested li elements under the inner ul do not match.
Example 2 — Child vs Descendant Count
Same markup, two selectors — see how depth changes the match count.
jQuery
var direct = $("ul.topnav > li").length;
var all = $("ul.topnav li").length;
$("#out").text(
"Direct children (>): " + direct + "\n" +
"All descendants (space): " + all
);
Direct span (direct)
Nested span
Direct spans: 1 | All spans: 2
How It Works
Structure. One span is a child of #content; another sits inside #inner.
Filter.#content > span keeps only the direct span.
Label. We append (direct) so you can see which matched.
Frequently Asked Questions
The child combinator (parent > child) selects only direct children of a parent. $("ul.topnav > li") matches top-level list items inside ul.topnav, but not li elements nested inside a sub-list.
A space is the descendant combinator — it matches at any nesting depth. The > combinator matches only first-level children. $("div span") finds every span inside div; $("div > span") finds only spans that are immediate children of div.
Yes. $("nav > ul > li > a") walks one level at a time — a direct ul under nav, that ul’s direct li children, and each li’s direct a children. Use this when you need a precise depth.
Both target direct children. $("parent > child") is a CSS selector string for one-shot queries. .children("child") is a traversal method — useful when you already have a jQuery object and want its immediate children.
Yes. The > combinator is standard CSS (Selectors Level 3) and has been in jQuery since 1.0. Prefer specific parents like $("ul.topnav > li") over overly broad queries.
Use > when nested markup could cause false matches — menus with sub-menus, tables inside tables, or cards with inner wrappers. Direct-child selection keeps the query precise.