The element > element selector — also called the child combinator — targets only direct children of a parent. It gives you precise control over nested HTML without accidental styling of deeper elements.
01
> combinator
Direct children.
02
Syntax
parent > child
03
Containers
First-level only.
04
Navigation
ul > li
05
vs space
Child vs descendant.
06
Clean CSS
Avoid bleed-through.
Fundamentals
Introduction
The element > element selector in CSS is a child combinator that selects elements which are direct children of a specified parent element.
This selector lets you target one level deep in the DOM tree. Styles apply to immediate children only and do not cascade to grandchildren or deeper nested elements.
Definition and Usage
Write the parent selector, a greater-than sign (>), then the child selector. The rule applies only when the child is an immediate descendant of the parent. If another element sits between them, the selector does not match.
💡
Beginner Tip
Think of > as “one level down only.” If you need all nested elements at any depth, use the descendant combinator (a space) instead: .parent p.
The child must be a direct descendant of the parent.
Grandchildren and deeper nested elements are not matched.
Spaces around > are conventional: .parent > p.
Works with element types, classes, IDs, and attribute selectors.
Can be chained: nav > ul > li for each level.
Related Selectors
element element — descendant combinator (any nested level)
element + element — adjacent sibling combinator
element ~ element — general sibling combinator
Cheat Sheet
⚡ Quick Reference
Question
Answer
Combinator symbol
> (greater-than)
Also called
Child combinator
Matches
Only direct children (one level deep)
Common patterns
.container > h1, ul > li, .content > p
Alternative for all nested
element element (descendant)
Browser support
All modern browsers
.container > h1ul > li.content > pnav > ul > li
Context
When to Use element > element
The child combinator is ideal when you need one-level precision:
Layout sections — Style only top-level blocks inside a container without affecting nested widgets.
Navigation menus — Target ul > li for top-level items while leaving dropdown sub-menus alone.
Article content — Style direct paragraphs in .content > p but not quotes inside nested divs.
Tables — Use table > thead or table > tbody for structural styling.
Component boundaries — Prevent styles from bleeding into child components rendered inside a parent.
Preview
👀 Live Preview
Only direct children of .child-demo-wrap are styled — the nested paragraph inside .child-demo-panel is not affected by > h3 or > .child-demo-panel rules on outer elements:
Main Title (direct child)
Paragraph inside the panel (not a direct child of .child-demo-wrap).
Hands-On
Examples Gallery
Practice the > combinator with containers, navigation, direct paragraphs, and child vs descendant comparison.
📜 Core Patterns
Style direct children inside a parent container.
Example 1 — Container direct children
Style the <h1> and .content div only when they are immediate children of .container.
Each <li> is a direct child of <ul class="menu">. If you add nested sub-menus with inner <ul> lists, .menu > li still targets only the top-level items.
📄 Precision Patterns
Limit styles to one nesting level and compare with descendant selectors.
Example 3 — Direct paragraphs only
Style paragraphs that are immediate children of .content, leaving nested paragraphs unchanged.
The descendant selector matches every <p> inside the parent at any depth. The child combinator stops at the first level, giving you tighter control over complex markup.
Watch Out
⚠️ Common Pitfalls
Expecting nested matches — > only selects direct children. Grandchildren need a separate rule or the descendant combinator.
Wrong HTML structure — If an extra wrapper div sits between parent and child, the selector will not match.
Confusing > with + — > is parent-to-child. + is sibling-to-sibling at the same level.
Over-specificity — Long chains like div > div > div > p are fragile when markup changes; prefer classes when structure varies.
A11y
♿ Accessibility
Semantic HTML — Use proper elements (nav, ul, li, main) so child selectors align with meaningful structure.
Navigation — When styling ul > li, ensure keyboard users can reach all menu items and sub-menus remain accessible.
Don’t hide content accidentally — Be careful with display: none on child selectors that might hide important nested content.
Focus styles — Child selectors for layout should not remove :focus outlines from interactive elements inside.
🧠 How element > element Works
1
Browser finds the parent
Every element matching the parent selector becomes a starting point.
Parent
2
> checks one level down
The browser looks only at immediate children of each matched parent.
Child
3
Child selector filters matches
Only direct children that match the second selector receive the styles.
Match
=
🎯
Precise one-level styling
Nested descendants stay untouched unless you target them separately.
Compatibility
Browser Compatibility
The child combinator (>) is supported in all modern browsers and has been part of CSS for decades.
✓ Universal · All browsers
Child combinator everywhere
element > element works reliably in Chrome, Firefox, Safari, Edge, and Opera.
99%Browser support
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions
Full support
OperaAll versions
Full support
> child combinator99% supported
Bottom line: The child combinator is safe for layout and navigation patterns in any modern project.
Wrap Up
Conclusion
The element > element child combinator is an essential tool for precise CSS targeting. It lets you style direct children without affecting deeper nested elements, leading to cleaner and more maintainable stylesheets.
Use it for containers, navigation, and component boundaries. When you need all nested elements, switch to the descendant combinator. Combine child selectors with classes for flexible, readable CSS.
Use .parent > .child when you need one-level precision
Combine with semantic HTML (nav > ul > li)
Compare with descendant selectors to avoid unintended matches
Add classes to children when markup depth varies
Keep selector chains readable with spaces around >
❌ Don’t
Expect > to match grandchildren
Confuse > with the adjacent sibling +
Build overly long fragile chains tied to exact DOM depth
Use child selectors when a simple class on the target is clearer
Forget that wrapper divs break direct parent-child relationships
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about >
Use these points when targeting direct children in your CSS.
5
Core concepts
▸01
Direct only
One level deep.
Purpose
📁02
Containers
Top-level blocks.
Pattern
☰03
ul > li
Menu items.
Nav
📄04
vs space
Child vs descendant.
Compare
🌐05
99% support
All browsers.
Compat
❓ Frequently Asked Questions
The child combinator (parent > child) selects elements that are direct children of the specified parent. Deeper nested descendants are not matched.
The > child combinator matches only direct children. The descendant combinator (a space) matches any nested level inside the parent.
Yes. Selectors like .container > h1, nav > .menu-item, and ul > li work the same way — the second part must be an immediate child of the first.
Use it when you need precise control — for example styling only top-level list items, direct table rows, or first-level sections without affecting nested components.
Yes. The > combinator has been supported in all modern browsers for many years and is safe to use in production.