---
id: howto-css-center-website
title: "How To - Center Website"
category: "Web_Recipes"
status: "draft"
verification_status: "conceptual"
canonical_id: ""
aliases: ["margin auto center page", "center page horizontally 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", "layout", "centering"]
raw_sources: ["https://www.w3schools.com/howto/howto_css_center_website.asp"]
applied_in: []
github_commit: ""
---

# [[HOWTO CSS Center Website]]

## 🎯 한 줄 통찰 (One-line insight)
`margin: auto` only centers a block horizontally if the element has an EXPLICIT width (here via `max-width`) — an unconstrained block always stretches to fill its parent, leaving no leftover space for the browser to distribute as equal left/right margins, which is the entire reason this recipe pairs `max-width: 500px` with `margin: auto` rather than using either alone; this is the simplest of all the centering recipes in this cookbook because it needs neither `position`, `transform`, nor Flexbox — just a width constraint plus auto margins. [S1]

## 🧠 핵심 개념 (Core concepts)
- **`margin: auto` requires a constrained width** — auto margins only distribute leftover horizontal space; a full-width block has none to distribute. [S1]
- **`max-width` instead of `width`** — allows the content wrapper to shrink on narrow viewports (spanning the full page below the breakpoint) while capping its width on wide screens. [S1]
- **No positioning/transform/flexbox needed** — the simplest technique in this cookbook's centering family, applicable to whole-page content wrappers rather than individual elements. [S1]

## 📖 세부 내용 (Details)
- `.content { max-width: 500px; margin: auto; }` applied to a wrapper `<div>` directly inside `<body>`. [S1]
- Below 500px viewport width, the content spans the full page (since `max-width` stops constraining once the viewport is narrower than it). [S1]

## ⚖️ 모순 및 업데이트 (Contradictions & updates)
없음 — 신규 레시피, 기존 문서와 모순되는 내용 없음.

## 🛠️ 적용 사례 (Applied in summary)
페이지 콘텐츠를 500px 폭으로 제한하고 margin:auto로 가로 중앙 정렬해, 500px보다 좁은 화면에서는 전체 폭을 차지하게 만드는 예제가 원문에서 직접 제시됨. [S1]

## 💻 코드 패턴 (Code patterns)
Centering a whole page's content with max-width + margin:auto (CSS):
```css
.content {
  max-width: 500px;
  margin: auto;
}
```

## ✅ 검증 상태 및 신뢰도
- **상태:** draft
- **검증 단계:** conceptual
- **출처 신뢰도:** B (W3Schools — widely used educational reference)
- **신뢰 점수:** 0.82
- **중복 검사 결과:** 신규 생성 (New discovery)

## 🔗 지식 그래프 (Knowledge Graph)
- **상위/루트:** [[W3Schools HOW TO]]
- **관련 개념:** [[HOWTO CSS Center Button]], [[HOWTO CSS Full Page]]
- **참조 맥락:** CSS Layout & Positioning 섹션.

## 📚 출처 (Sources)
- [S1] W3Schools — How To - Center Website — https://www.w3schools.com/howto/howto_css_center_website.asp

## 📝 변경 이력 (Change history)
- 2026-07-04: Initial draft synthesized from the W3Schools "How To - Center Website" recipe (Astra wiki-curation, P-Reinforce v3.1 format).
