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>
This commit is contained in:
@@ -0,0 +1,136 @@
|
||||
---
|
||||
id: css-box-sizing
|
||||
title: "CSS Box Sizing"
|
||||
category: "Frontend"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["box-sizing", "border-box", "content-box", "CSS box model sizing", "include padding border in width"]
|
||||
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", "box-model", "layout"]
|
||||
raw_sources: ["https://www.w3schools.com/css/css3_box-sizing.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSS Box Sizing]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The `box-sizing` property controls whether an element's declared width/height include its padding and border, and setting it to `border-box` makes sizing predictable so padded boxes don't grow larger than intended. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Default behavior** — by default, an element's actual rendered width and height include the padding and border *added on top of* the specified `width`/`height`. [S1]
|
||||
- **The sizing formula (default)** — `width + padding + border = actual width of an element`, and `height + padding + border = actual height of an element`. [S1]
|
||||
- **The problem** — two divs with identical `width: 300px` / `height: 100px` appear different sizes if one has padding; the padded one is larger. [S1]
|
||||
- **The fix** — `box-sizing` lets you include padding and borders within the total declared width/height. [S1]
|
||||
- **Recommended default** — applying `box-sizing: border-box` to all elements via `*` makes layout sizing consistent. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **border-box pattern** — set `box-sizing: border-box;` so the declared width/height *contain* padding and border instead of being added to them. [S1]
|
||||
- **Universal reset pattern** — `* { box-sizing: border-box; }` applies predictable sizing to every element. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
By default, the actual width and height of an element include the padding and borders added to the specified dimensions: [S1]
|
||||
- `width + padding + border = actual width of an element` [S1]
|
||||
- `height + padding + border = actual height of an element` [S1]
|
||||
|
||||
This means two divs given the same `width` (300px) and `height` (100px) can appear different — the one with 50px padding is larger because the padding is added to the specified width/height. The `box-sizing` property solves this by allowing padding and borders to be included in the total width/height calculation. [S1]
|
||||
|
||||
**Example 1 — without `box-sizing` (the problem)** [S1]
|
||||
```css
|
||||
.div1 {
|
||||
width: 300px;
|
||||
height: 100px;
|
||||
border: 1px solid blue;
|
||||
}
|
||||
|
||||
.div2 {
|
||||
width: 300px;
|
||||
height: 100px;
|
||||
padding: 50px;
|
||||
border: 1px solid red;
|
||||
}
|
||||
```
|
||||
|
||||
**Example 2 — with `box-sizing: border-box` (the solution)** [S1]
|
||||
```css
|
||||
.div1 {
|
||||
width: 300px;
|
||||
height: 100px;
|
||||
border: 1px solid blue;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.div2 {
|
||||
width: 300px;
|
||||
height: 100px;
|
||||
padding: 50px;
|
||||
border: 1px solid red;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
```
|
||||
|
||||
**Example 3 — recommended universal application** [S1]
|
||||
```css
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
```
|
||||
|
||||
**Property reference** [S1]
|
||||
|
||||
| Property | Description |
|
||||
|----------|-------------|
|
||||
| `box-sizing` | Defines how the width and height of an element are calculated: should they include padding and borders, or not |
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
The page's applied examples contrast `.div1` and `.div2` first without `box-sizing` (they render at different sizes) and then with `box-sizing: border-box` (they render identically), and finally recommend the `* { box-sizing: border-box; }` universal reset. No external project/commit applications found in the source.
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Predictable element sizing (language: CSS):
|
||||
```css
|
||||
.box {
|
||||
width: 300px;
|
||||
height: 100px;
|
||||
padding: 50px;
|
||||
border: 1px solid red;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
```
|
||||
Universal reset (language: CSS):
|
||||
```css
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
```
|
||||
|
||||
## ⚖️ 비교 및 선택 기준 (Comparison & decision criteria)
|
||||
- **Default (content-box) sizing** — `width`/`height` describe only the content area; padding and border are added on top, so the rendered box is larger than the declared size. Use when you specifically want the content area to be a fixed size. [S1]
|
||||
- **`border-box` sizing** — padding and border are included within the declared `width`/`height`, so a `300px` box stays `300px` regardless of padding. The page recommends this (including applying it to all elements via `*`) for predictable layouts. [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 Box Model]], [[CSS Padding]], [[CSS Border]], [[CSS Width and Max-width]]
|
||||
- **참조 맥락:** Referenced whenever layout sizing must stay predictable across elements that carry padding or borders.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — CSS Box Sizing — https://www.w3schools.com/css/css3_box-sizing.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-06-23: Initial draft synthesized from the W3Schools "CSS Box Sizing" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
Reference in New Issue
Block a user