--- id: css-grouping-selectors title: "CSS Grouping Selectors" category: "Frontend" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["grouping selector", "comma selector", "shared declarations", "universal selector", "CSS code minimization"] duplicate_of: "" source_trust_level: "B" confidence_score: 0.88 created_at: 2026-06-23 updated_at: 2026-06-23 review_reason: "" merge_history: [] tags: ["css", "web", "frontend", "w3schools", "selectors"] raw_sources: ["https://www.w3schools.com/css/css_selectors_grouping.asp"] applied_in: [] github_commit: "" --- # [[CSS Grouping Selectors]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) When several elements share identical style definitions, group their selectors with commas into a single rule to minimize code; the universal selector `*` applies a declaration to every element on the page. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **Universal selector** β€” `*` selects all HTML elements on the page. [S1] - **Grouping selector** β€” selects all the HTML elements with the same style definitions. [S1] - **Comma syntax** β€” to group selectors, separate each selector with a comma. [S1] - **Benefit** β€” grouping minimizes code when multiple elements share identical style definitions. [S1] ## 🧩 μΆ”μΆœλœ νŒ¨ν„΄ (Extracted patterns) - **Collapse duplicates** β€” replace several rules with identical declarations by one comma-separated selector list. [S1] - **Whole-page baseline** β€” use `*` to apply a single declaration block to every element. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) **The CSS universal selector** (`*`) selects all HTML elements on the page. [S1] ```css * { text-align: center; color: blue; } ``` **The CSS grouping selector** selects all the HTML elements with the same style definitions. [S1] Look at the following CSS code (the `h1`, `h2`, and `p` elements have the same style definitions): [S1] ```css h1 { text-align: center; color: red; } h2 { text-align: center; color: red; } p { text-align: center; color: red; } ``` It will be better to group the selectors, to minimize the code. To group selectors, separate each selector with a comma. [S1] ```css h1, h2, p { text-align: center; color: red; } ``` ## πŸ› οΈ 적용 사둀 (Applied in summary) The page's own example groups `h1`, `h2`, and `p` β€” which originally carried three identical rules β€” into one comma-separated rule. No external project/commit applications found in the source. ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Grouping selectors that share declarations (language: CSS): ```css h1, h2, p { text-align: center; color: red; } ``` Universal selector: ```css * { text-align: center; color: blue; } ``` ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (Contradictions & updates) No contradictions found in the source. ## βœ… 검증 μƒνƒœ 및 신뒰도 - **μƒνƒœ:** draft - **검증 단계:** conceptual (μ‹€μ œ 적용 사둀 발견 μ‹œ applied/validated둜 승격 κ°€λŠ₯) - **좜처 신뒰도:** B (W3Schools β€” widely used educational reference, not a primary standards body) - **μ‹ λ’° 점수:** 0.88 - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— 지식 κ·Έλž˜ν”„ (Knowledge Graph) - **μƒμœ„/루트:** [[CSS Tutorial]] - **κ΄€λ ¨ κ°œλ…:** [[CSS Selectors]], [[CSS Syntax]], [[CSS Introduction]] - **μ°Έμ‘° λ§₯락:** Referenced when reducing duplication across rules that share the same declarations. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” CSS Grouping Selectors β€” https://www.w3schools.com/css/css_selectors_grouping.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-06-23: Initial draft synthesized from the W3Schools "CSS Grouping Selectors" page (Astra wiki-curation, P-Reinforce v3.1 format).