--- id: howto-css-button-group title: "How To - Button Group" category: "Web_Recipes" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["btn-group horizontal CSS"] duplicate_of: "" source_trust_level: "B" confidence_score: 0.82 created_at: 2026-07-04 updated_at: 2026-07-04 review_reason: "" merge_history: [] tags: ["howto", "css", "w3schools", "buttons"] raw_sources: ["https://www.w3schools.com/howto/howto_css_button_group.asp"] applied_in: [] github_commit: "" --- # [[HOWTO CSS Button Group]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) `:not(:last-child) { border-right: none; }` solves a problem unique to adjacent bordered buttons β€” floating buttons side by side with individual borders would double up the border between each pair (right edge of one touching the left edge of the next), so this `:not()` selector strips the right border from every button EXCEPT the last, leaving a single shared-looking seam between buttons instead of a visibly doubled line. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **`float: left` buttons + clearfix** β€” the same clearfix pattern from the layout recipes, needed here because the button group container would otherwise collapse. [S1] - **`:not(:last-child) { border-right: none; }`** β€” prevents double borders between adjacent buttons by removing the right border from all but the final button. [S1] - **Justified/full-width variant** β€” set the container to `width: 100%` and give each button an explicit percentage width (`33.3%` for 3 buttons, `25%` for 4) so the group spans the full container width evenly. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) - Horizontal group: `.btn-group button { float: left; border: 1px solid green; } .btn-group button:not(:last-child) { border-right: none; } .btn-group:after { content: ""; clear: both; display: table; }`. [S1] - Justified variant: inline `style="width:33.3%"` on each of 3 buttons inside a `width:100%` container. [S1] ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (Contradictions & updates) μ—†μŒ β€” μ‹ κ·œ λ ˆμ‹œν”Ό, κΈ°μ‘΄ λ¬Έμ„œμ™€ λͺ¨μˆœλ˜λŠ” λ‚΄μš© μ—†μŒ. ## πŸ› οΈ 적용 사둀 (Applied in summary) Apple/Samsung/Sony λ²„νŠΌ 3개λ₯Ό 이쀑 ν…Œλ‘λ¦¬ 없이 λ‚˜λž€νžˆ λ°°μΉ˜ν•˜κ³ , μ»¨ν…Œμ΄λ„ˆ 전체 폭에 맞좰 κ· λ“± λΆ„ν• ν•˜λŠ” justified 버전도 ν•¨κ»˜ μ œμ‹œλ¨. [S1] ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Button group without doubled borders between buttons (CSS): ```css .btn-group button { float: left; border: 1px solid green; } .btn-group button:not(:last-child) { border-right: none; } .btn-group:after { content: ""; clear: both; display: table; } ``` ## βœ… 검증 μƒνƒœ 및 신뒰도 - **μƒνƒœ:** draft - **검증 단계:** conceptual - **좜처 신뒰도:** B (W3Schools β€” widely used educational reference) - **μ‹ λ’° 점수:** 0.82 - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— 지식 κ·Έλž˜ν”„ (Knowledge Graph) - **μƒμœ„/루트:** [[W3Schools HOW TO]] - **κ΄€λ ¨ κ°œλ…:** [[HOWTO CSS Button Group Vertical]], [[HOWTO CSS Block Buttons]] - **μ°Έμ‘° λ§₯락:** CSS Buttons μ„Ήμ…˜. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” How To - Button Group β€” https://www.w3schools.com/howto/howto_css_button_group.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-07-04: Initial draft synthesized from the W3Schools "How To - Button Group" recipe (Astra wiki-curation, P-Reinforce v3.1 format).