The element element selector — written with a space between selectors — is the descendant combinator. It targets elements nested inside an ancestor at any depth.
01
Space
Combinator.
02
Any depth
Nested match.
03
div p
Classic pattern.
04
Scoped
.article p
05
vs >
All vs direct.
06
Navigation
nav a links.
Fundamentals
Introduction
The CSS element element selector, also called the descendant combinator, selects elements that are nested inside a specified ancestor. The space between selectors means “anywhere inside,” no matter how deep the nesting goes.
This is one of the most common selector patterns in CSS. It lets you style paragraphs inside an article, links inside a navigation bar, or list items inside a sidebar — all based on where they sit in the HTML tree.
Definition and Usage
Write the ancestor selector, a space, then the descendant selector: div p or .container li. Every matching descendant receives the styles, whether it is a direct child or nested several levels deep.
💡
Beginner Tip
If you only want direct children, use the child combinator > instead: .parent > p. A space matches all nested levels; > matches one level only.
Foundation
📝 Syntax
The signature of the descendant combinator is:
syntax.css
ancestor descendant{/* CSS properties */}
Basic Example
descendant-basic.css
div p{color:#2563eb;font-weight:600;}.article p{line-height:1.65;color:#334155;}
Syntax Rules
A space between selectors creates the descendant relationship.
Matches descendants at any nesting depth, not just direct children.
Works with types, classes, IDs, and attribute selectors on either side.
Chain multiple levels: nav ul li a targets links inside list items inside lists inside nav.
Add an ancestor to narrow scope: .sidebar p instead of bare p.
Related Selectors
element > element — child combinator (direct children only)
element + element — adjacent sibling combinator
element ~ element — general sibling combinator
Cheat Sheet
⚡ Quick Reference
Question
Answer
Combinator
Space (whitespace)
Also called
Descendant combinator
Matches
Any nested descendant at any depth
Common patterns
div p, .article p, nav a
Direct children only
Use element > element instead
Browser support
All browsers (CSS1)
div p.article pnav anav ul li a
Context
When to Use element element
The descendant combinator is ideal when nesting depth varies:
Article content — Style all <p> tags inside .article, including those in nested blocks.
Navigation — Target nav a for top-level and dropdown links alike.
Cards and widgets — Style .card h3 and .card p regardless of wrapper divs inside.
Tables — Use table td to style cells at any row depth in complex layouts.
Scoped typography — Limit body text styles to .content p without affecting the footer.
Preview
👀 Live Preview
All <p> elements inside the <div> match div p — including the nested paragraph. The footer paragraph is outside the div:
Paragraph inside the demo div.
Nested paragraph — also styled by div p.
Hands-On
Examples Gallery
Practice the descendant combinator with div p, scoped articles, navigation links, and comparison with the child combinator.
📜 Core Patterns
Target nested elements at any depth inside an ancestor.
Example 1 — Paragraphs inside div
Style every <p> that is a descendant of any <div>, including deeply nested ones.
The descendant selector casts a wider net. When you need one-level precision, switch to the child combinator >.
Watch Out
⚠️ Common Pitfalls
Too broad — Selectors like div p or body a may style more elements than you expect as HTML grows.
Unintended nesting — A widget added inside .article will inherit .article p styles unless you override them.
Confusing space with + or > — A space means descendant; + is next sibling; > is direct child.
Over-specific chains — Long selectors like div div div p are fragile; prefer a class on the target container.
Performance on huge pages — Very generic descendant selectors on large documents can slow style recalculation slightly; scope with classes when possible.
A11y
♿ Accessibility
Semantic structure — Use meaningful elements (nav, main, article) so descendant selectors align with document structure.
Link styles — When styling nav a, ensure focus and hover states remain visible for keyboard users.
Don’t hide content — Be careful with display: none on broad descendant selectors that might hide important nested content.
Color contrast — Descendant-scoped text colors must still meet WCAG contrast requirements.
🧠 How element element Works
1
Browser finds ancestors
Every element matching the first selector becomes a starting point.
Ancestor
2
Space searches descendants
The browser looks at all nested elements inside each matched ancestor.
Descend
3
Second selector filters
Any descendant matching the second part of the selector gets the styles.
Match
=
🌳
Nested styling at any depth
Children, grandchildren, and deeper descendants all match.
Compatibility
Browser Compatibility
The descendant combinator has been supported since CSS1 and works in every browser ever made.
✓ Universal · CSS1
Descendant selectors everywhere
element element works in Chrome, Firefox, Safari, Edge, Opera, and all legacy browsers.
100%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
element element descendant combinator100% supported
Bottom line: The descendant combinator is the most fundamental nesting pattern in CSS and is safe to use everywhere.
Wrap Up
Conclusion
The element element descendant selector is a cornerstone of CSS. It lets you target nested elements at any depth inside an ancestor, making it perfect for articles, navigation, and scoped component styling.
Use it when nesting varies, but scope with classes to avoid unintended matches. When you need direct children only, reach for the child combinator > instead.
Rely on deep nesting alone when a class would be clearer
Forget that descendant selectors have low specificity alone
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about descendant selectors
Use these points when targeting nested elements.
5
Core concepts
⋯01
Space
Combinator.
Syntax
🌳02
Any depth
All nested.
Scope
📄03
div p
Classic use.
Pattern
▸04
vs >
All vs direct.
Compare
🌐05
100% support
CSS1.
Compat
❓ Frequently Asked Questions
The descendant combinator (parent element) selects elements nested inside a specified ancestor at any depth. A space between selectors means the second element can be a child, grandchild, or deeper descendant.
A space is the descendant combinator and matches all nested levels. The > child combinator matches only direct children one level deep.
Put a space between two selectors: div p, .article li, or nav a. The second part matches any descendant of the first.
Scoping with an ancestor selector limits styles to a specific section, reducing unintended matches elsewhere on the page.
Yes. The descendant combinator has been part of CSS since CSS1 and works in every browser.