Files
2nd/10_Wiki/Topic_HTML/HTML_Div.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

171 lines
5.6 KiB
Markdown

---
id: html-div
title: "HTML Div"
category: "Frontend"
status: "draft"
verification_status: "conceptual"
canonical_id: ""
aliases: ["div element", "div tag", "block container", "div layout", "div centering"]
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: ["html", "web", "frontend", "w3schools", "layout"]
raw_sources: ["https://www.w3schools.com/html/html_div.asp"]
applied_in: []
github_commit: ""
---
# [[HTML Div]]
## 🎯 한 줄 통찰 (One-line insight)
The `<div>` element is a block-level container that groups other HTML elements together so they can be styled and laid out as a unit. [S1]
## 🧠 핵심 개념 (Core concepts)
- **`<div>` is a container** for other HTML elements. [S1]
- **Block-level by default** — the `<div>` element is by default a block element, meaning it takes all available width and comes with line breaks before and after. [S1]
- **No required attributes** — the `<div>` element has no required attributes, but `style`, `class`, and `id` are common. [S1]
- **Centering** — to center a non-full-width `<div>`, set a width and the CSS `margin` property to `auto`. [S1]
- **Side-by-side layout** — multiple `<div>` elements can be aligned horizontally using Float, Inline-block, Flexbox, or Grid. [S1]
## 🧩 추출된 패턴 (Extracted patterns)
- **Grouping pattern** — wrap a heading and its paragraph(s) in a `<div>` to treat them as one logical section. [S1]
- **Centering pattern** — give the `<div>` a fixed width and `margin: auto` to center it horizontally. [S1]
- **Horizontal layout pattern** — apply a layout technique (Float / Inline-block / Flexbox / Grid) to place several `<div>` containers in columns. [S1]
## 📖 세부 내용 (Details)
**The `<div>` Element.** The `<div>` element is used as a container for other HTML elements. The `<div>` element is by default a block element, meaning that it takes all available width, and comes with line breaks before and after. The `<div>` element has no required attributes, but `style`, `class`, and `id` are common. [S1]
Grouping a section with a `<div>`: [S1]
```html
<div>
<h2>London</h2>
<p>London is the capital city of England.</p>
</div>
```
**Center align a `<div>` element.** If you have a `<div>` element that is not 100% wide, and you want to center-align it, set the CSS `margin` property to `auto`. [S1]
```css
div {
width: 300px;
margin: auto;
}
```
**Multiple `<div>` elements.** You can have many `<div>` containers on the same page. [S1]
```html
<div>
<h2>London</h2>
<p>London is the capital city of England.</p>
</div>
<div>
<h2>Oslo</h2>
<p>Oslo is the capital city of Norway.</p>
</div>
```
**Aligning `<div>` elements side by side.** There are several CSS methods to lay out `<div>` elements horizontally. [S1]
*Float* — use `float: left` with percentage widths (e.g. 33% for three columns): [S1]
```css
.mycontainer {
width: 100%;
overflow: auto;
}
.mycontainer div {
width: 33%;
float: left;
}
```
*Inline-block* — change the display property from block to `inline-block`: [S1]
```css
div {
width: 30%;
display: inline-block;
}
```
*Flexbox* — apply `display: flex` on a parent container: [S1]
```css
.mycontainer {
display: flex;
}
.mycontainer > div {
width: 33%;
}
```
*Grid* — use `display: grid` with the `grid-template-columns` property: [S1]
```css
.grid-container {
display: grid;
grid-template-columns: 33% 33% 33%;
}
```
**HTML Tag Reference.** [S1]
| Tag | Description |
|---|---|
| `<div>` | Defines a section in a document (block-level) |
## 🛠️ 적용 사례 (Applied in summary)
The city-grouping examples (London, Oslo) and the four horizontal-layout techniques (Float, Inline-block, Flexbox, Grid) are the canonical applied examples. No external project/commit applications found in the source.
## 💻 코드 패턴 (Code patterns)
Container div (HTML):
```html
<div>
<h2>Title</h2>
<p>Content.</p>
</div>
```
Centered div (CSS):
```css
div {
width: 300px;
margin: auto;
}
```
Three-column flexbox (CSS):
```css
.mycontainer {
display: flex;
}
.mycontainer > div {
width: 33%;
}
```
## ⚖️ 비교 및 선택 기준 (Comparison & decision criteria)
For aligning `<div>` elements side by side, the source presents four approaches: [S1]
- **Float** — `float: left` with percentage widths; container uses `overflow: auto`.
- **Inline-block** — set `display: inline-block` and a width on each div.
- **Flexbox** — `display: flex` on the parent container (modern, flexible).
- **Grid** — `display: grid` with `grid-template-columns` (advanced layout control).
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
No contradictions found in the source. [S1]
## ✅ 검증 상태 및 신뢰도
- **상태:** draft
- **검증 단계:** conceptual (실제 적용 사례 발견 시 applied/validated로 승격 가능)
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
- **신뢰 점수:** 0.88
- **중복 검사 결과:** 신규 생성 (New discovery)
## 🔗 지식 그래프 (Knowledge Graph)
- **상위/루트:** [[HTML Tutorial]]
- **관련 개념:** [[HTML Block and Inline]], [[HTML Classes]], [[HTML Id]], [[HTML Iframes]]
- **참조 맥락:** Referenced whenever grouping or laying out page sections as block-level containers.
## 📚 출처 (Sources)
- [S1] W3Schools — HTML Div Element — https://www.w3schools.com/html/html_div.asp
## 📝 변경 이력 (Change history)
- 2026-06-23: Initial draft synthesized from the W3Schools "HTML Div Element" page (Astra wiki-curation, P-Reinforce v3.1 format).