Combinators

๐ŸŽจ CSS3+ ๐ŸŸข Chapter 4 of 49 ๐Ÿ“‚ Phase 02: Selectors ๐Ÿ“… 2026 Edition
๐Ÿ“Œ Covered in this chapter: Descendant ยท Child ยท Adjacent Sibling ยท General Sibling ยท Combining ยท Readability ยท Component-Scoped ยท Avoid Complex Selectors
Welcome to Chapter 4: Combinators โ€” part of the CSS Complete Roadmap. This lesson covers all subtopics with clear explanations, code examples, and best practices used in professional web development.
1CSS Combinators Overview

Combinators two selectors madhya relationship define chestayi โ€” parent-child, sibling connections based ga styles target cheyadaniki.

CombinatorSymbolMeaning
DescendantspaceAny nested level lo match
Child>Direct child only
Adjacent sibling+Immediately next sibling
General sibling~All following siblings
2Descendant & Child Combinators
CSS โ€” Combinatorsโ–ถ Try in Editor
/* Descendant โ€” any p inside .card at any depth */
.card p {
  color: #555;
}

/* Child โ€” only direct h2 children of .card */
.card > h2 {
  margin-bottom: 10px;
  font-size: 1.25rem;
}

Component-scoped selectors: .card > h2 card component lo matrame heading style apply chestundi โ€” global h2 ni affect cheyadu.

3Sibling Combinators
CSS
/* Adjacent sibling โ€” p immediately after h2 */
h2 + p {
  margin-top: 0;
  font-size: 1.1rem;
}

/* General sibling โ€” all p siblings after h2 */
h2 ~ p {
  color: #64748b;
}
4Combining Selectors & Readability
CSS โ€” Combined
nav.main-nav > ul > li.active > a {
  color: #3b82f6;
  font-weight: 700;
}
โš ๏ธ Avoid Overly Complex Selectors

Long chained selectors specificity ekkuva, maintenance kashtam. Instead use a class: .nav-link--active { ... }. Selector readability and reusability always prioritize cheyandi.

OC
Written by Our Compiler Technical Editorial Team
Reviewed for accuracy ยท CSS Complete Roadmap ยท Last updated August 2026