Files
2nd/10_Wiki/Topic_CSS/CSS_Margin_Collapse.md
T
koriweb 9609c04755 docs(10_Wiki): W3Schools 위키화 — HTML/CSS/JavaScript(core)
W3Schools 튜토리얼을 P-Reinforce v3.1 포맷으로 위키화(영어 본문, 한/영 섹션 헤더).
- Topic_HTML: 59문서 (튜토리얼+예제, 레퍼런스/메타 제외)
- Topic_CSS: 190문서 (메인 + Advanced/Flexbox/Grid/RWD 전체)
- Topic_JavaScript: 120문서 (코어 언어; Temporal/DOM상세/BOM/WebAPI/AJAX/jQuery/Graphics 등은 후속)
각 폴더 00_INDEX.md(MOC) 포함. 코드 verbatim, 미확인분은 "Not found in source" 표기.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-23 19:21:18 +09:00

89 lines
3.7 KiB
Markdown

---
id: css-margin-collapse
title: "CSS Margin Collapse"
category: "Frontend"
status: "draft"
verification_status: "conceptual"
canonical_id: ""
aliases: ["margin collapse", "collapsing margins", "CSS margin collapsing", "vertical margin collapse", "largest margin wins"]
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", "margin", "box-model"]
raw_sources: ["https://www.w3schools.com/css/css_margin_collapse.asp"]
applied_in: []
github_commit: ""
---
# [[CSS Margin Collapse]]
## 🎯 한 줄 통찰 (One-line insight)
Top and bottom margins of elements are sometimes collapsed into a single margin that is equal to the largest of the two margins — this only happens with top and bottom margins, never left and right. [S1]
## 🧠 핵심 개념 (Core concepts)
- **Definition** — top and bottom margins of elements are sometimes collapsed into a single margin that is equal to the largest of the two margins. [S1]
- **Largest wins** — the resulting single margin equals the larger of the two adjacent margins, not their sum. [S1]
- **Vertical only** — this does not happen on left and right margins, only top and bottom margins. [S1]
## 🧩 추출된 패턴 (Extracted patterns)
- **max, not sum** — when two vertical margins meet, the gap is `max(margin_a, margin_b)`, not `margin_a + margin_b`. [S1]
- **Horizontal exemption** — never rely on collapse for left/right spacing; it applies only to top/bottom. [S1]
## 📖 세부 내용 (Details)
**CSS Margin Collapse** [S1]
Top and bottom margins of elements are sometimes collapsed into a single margin that is equal to the largest of the two margins.
This does not happen on left and right margins! Only top and bottom margins! [S1]
**Example** — an `h1` with a bottom margin and an `h2` with a top margin: [S1]
```css
h1 {
margin: 0 0 50px 0;
}
h2 {
margin: 20px 0 0 0;
}
```
The `h1` element has a bottom margin of 50px and the `h2` element has a top margin set to 20px. Common sense would seem to suggest that the vertical margin between the `h1` and the `h2` would be a total of 70px (50px + 20px). But due to margin collapse, the actual margin ends up being 50px. [S1]
## 🛠️ 적용 사례 (Applied in summary)
The page's own applied example is the `h1`/`h2` stylesheet above, which demonstrates that adjacent 50px and 20px vertical margins collapse to a single 50px gap rather than summing to 70px. No external project/commit applications found in the source.
## 💻 코드 패턴 (Code patterns)
Adjacent vertical margins that collapse to the larger value (language: CSS):
```css
h1 {
margin: 0 0 50px 0;
}
h2 {
margin: 20px 0 0 0;
}
```
## ⚖️ 모순 및 업데이트 (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 Margins]], [[CSS Border Sides]], [[CSS Border Shorthand]]
- **참조 맥락:** A box-model gotcha to keep in mind whenever vertical spacing between stacked elements matters.
## 📚 출처 (Sources)
- [S1] W3Schools — CSS Margin Collapse — https://www.w3schools.com/css/css_margin_collapse.asp
## 📝 변경 이력 (Change history)
- 2026-06-23: Initial draft synthesized from the W3Schools "CSS Margin Collapse" page (Astra wiki-curation, P-Reinforce v3.1 format).