--- 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 that are immediate children of a `
` element placed immediately after a `
` elements that are siblings of (and come after) a `
` 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).