--- id: css-combinators title: "CSS Combinators" category: "Frontend" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["combinators", "descendant selector", "child selector", "sibling selector", "selector relationships"] duplicate_of: "" source_trust_level: "B" confidence_score: 0.89 created_at: 2026-06-23 updated_at: 2026-06-23 review_reason: "" merge_history: [] tags: ["css", "web", "frontend", "w3schools", "selectors", "combinators"] raw_sources: ["https://www.w3schools.com/css/css_combinators.asp"] applied_in: [] github_commit: "" --- # [[CSS Combinators]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) A combinator defines the relationship between two or more selectors, letting you target elements by their position relative to another element β€” descendants (space), direct children (`>`), the next sibling (`+`), or all following siblings (`~`). [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **What a combinator is** β€” something that defines the relationship between two or more selectors. [S1] - **Descendant combinator (space)** β€” matches all elements that are descendants (children, grandchildren, etc.) of a specified element. [S1] - **Child combinator (`>`)** β€” selects all elements that are direct children of a specified element. [S1] - **Next sibling combinator (`+`)** β€” selects an element that is directly after a specific element (the first adjacent sibling). [S1] - **Subsequent-sibling combinator (`~`)** β€” selects all elements that are next siblings of a specified element. [S1] ## 🧩 μΆ”μΆœλœ νŒ¨ν„΄ (Extracted patterns) - **Relationship-based selection** β€” instead of adding classes, target elements by structural relationship (`div p`, `div > p`, `div + p`, `div ~ p`). [S1] - **Direct-child vs any-descendant** β€” use a space to reach any depth, `>` to restrict to immediate children. [S1] - **One-sibling vs all-siblings** β€” `+` matches only the first following sibling, `~` matches every following sibling. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) **Definition** A combinator is something that defines the relationship between two or more selectors. [S1] **Descendant Combinator (space)** The descendant combinator matches all elements that are descendants (children, grandchildren, etc.) of a specified element. The following example selects all `

` elements inside `

` elements: [S1] ```css div p { background-color: yellow; } ``` **Child Combinator (`>`)** The child combinator selects all elements that are direct children of a specified element. The following example selects all `

` elements that are immediate children of a `

`: [S1] ```css div > p { background-color: yellow; } ``` **Next Sibling Combinator (`+`)** The next sibling combinator is used to select an element that is directly after a specific element. Sibling elements must have the same parent element, and "adjacent" means "immediately following". The following example selects the first `

` element placed immediately after a `

`: [S1] ```css div + p { background-color: yellow; } ``` **Subsequent-sibling Combinator (`~`)** The subsequent-sibling combinator selects all elements that are next siblings of a specified element. The following example selects all `

` elements that are siblings of (and come after) a `

`: [S1] ```css div ~ p { background-color: yellow; } ``` The page references a complete CSS Combinators Reference for additional details. [S1] ## πŸ› οΈ 적용 사둀 (Applied in summary) The page's own applied examples demonstrate each of the four combinators by setting `background-color: yellow;` on the matched `

` elements. No external project/commit applications found in the source. ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) The four combinators (language: CSS): ```css div p { background-color: yellow; } /* descendant */ div > p { background-color: yellow; } /* direct child */ div + p { background-color: yellow; } /* next sibling */ div ~ p { background-color: yellow; } /* all following siblings */ ``` ## βš–οΈ 비ꡐ 및 선택 κΈ°μ€€ (Comparison & decision criteria) - **Descendant (space) vs Child (`>`)** β€” space matches descendants at any depth; `>` restricts to immediate children only. [S1] - **Next sibling (`+`) vs Subsequent sibling (`~`)** β€” `+` matches only the single element directly following; `~` matches every following sibling with the same parent. [S1] ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (Contradictions & updates) No contradictions found in the source. ## βœ… 검증 μƒνƒœ 및 신뒰도 - **μƒνƒœ:** draft - **검증 단계:** conceptual (μ‹€μ œ 적용 사둀 발견 μ‹œ applied/validated둜 승격 κ°€λŠ₯) - **좜처 신뒰도:** B (W3Schools β€” widely used educational reference, not a primary standards body) - **μ‹ λ’° 점수:** 0.89 - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— 지식 κ·Έλž˜ν”„ (Knowledge Graph) - **μƒμœ„/루트:** [[CSS Tutorial]] - **κ΄€λ ¨ κ°œλ…:** [[CSS Selectors]], [[CSS Pseudo-classes]], [[CSS Pseudo-elements]], [[CSS Syntax]] - **μ°Έμ‘° λ§₯락:** Referenced whenever you need to select elements by their structural relationship rather than by class or id. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” CSS Combinators β€” https://www.w3schools.com/css/css_combinators.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-06-23: Initial draft synthesized from the W3Schools "CSS Combinators" page (Astra wiki-curation, P-Reinforce v3.1 format).