--- id: css-vertical-align title: "CSS Vertical Align" category: "Frontend" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["vertical align", "vertical centering", "flexbox center", "grid place-items", "transform translate center"] 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", "alignment", "flexbox", "grid"] raw_sources: ["https://www.w3schools.com/css/css_align_vertical.asp"] applied_in: [] github_commit: "" --- # [[CSS Vertical Align]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) Modern CSS centers content vertically with three approaches β€” Flexbox (`align-items: center`), Grid (`place-items: center`), or Position + Transform (`top/left: 50%` with `translate(-50%, -50%)`) β€” the last being the common technique for elements of unknown or dynamic dimensions. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **Flexbox vertical centering** β€” `display: flex` with `justify-content: center` and `align-items: center` centers content within a sized container. [S1] - **Grid vertical centering** β€” `display: grid` with `place-items: center` achieves the same centering effect. [S1] - **Position + Transform** β€” `position: absolute` with `top: 50%`, `left: 50%`, and `transform: translate(-50%, -50%)` centers content. [S1] - **Use Position + Transform for unknown sizes** β€” it is a common technique when dealing with elements of unknown or dynamic dimensions. [S1] - **Container setup** β€” the examples use a 200px-height container with a 3px solid green border. [S1] ## 🧩 μΆ”μΆœλœ νŒ¨ν„΄ (Extracted patterns) - **Flexbox both-axis center** β€” `display: flex; justify-content: center; align-items: center;`. [S1] - **Grid one-liner center** β€” `display: grid; place-items: center;`. [S1] - **Translate -50% center** β€” absolutely position the child at 50%/50% then pull it back by half its own size with `translate(-50%, -50%)`. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) **Center Align with Flexbox** [S1] ```css .center { display: flex; justify-content: center; align-items: center; height: 200px; border: 3px solid green; } ``` **Center Align with Grid** [S1] ```css .center { display: grid; place-items: center; height: 200px; border: 3px solid green; } ``` **Center Align with `position` and `transform`** For elements of unknown or dynamic dimensions, this is a common technique. The example sets `margin: 0` on the paragraph and centers it: [S1] ```css .container p { margin: 0; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); } ``` The page directs readers to the 2D Transforms chapter for a deeper understanding of the `transform` property. [S1] ## πŸ› οΈ 적용 사둀 (Applied in summary) The page's own applied examples are vertically centering content with Flexbox, with Grid (`place-items`), and with Position + Transform inside a 200px-height bordered container. No external project/commit applications found in the source. ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Position + transform centering (language: CSS): ```css .container p { margin: 0; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); } ``` ## βš–οΈ 비ꡐ 및 선택 κΈ°μ€€ (Comparison & decision criteria) - **Flexbox vs Grid vs Position+Transform** β€” Flexbox and Grid are modern container-driven techniques for vertical centering; Position + Transform is the common choice when the element has unknown or dynamic dimensions because `translate(-50%, -50%)` offsets by the element's own measured size. [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 Center Align]], [[CSS Horizontal Align]], [[CSS Flexbox]], [[CSS Grid]] - **μ°Έμ‘° λ§₯락:** Referenced when vertically centering content, especially elements whose height is not known in advance. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” CSS Vertical Align β€” https://www.w3schools.com/css/css_align_vertical.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-06-23: Initial draft synthesized from the W3Schools "CSS Vertical Align" page (Astra wiki-curation, P-Reinforce v3.1 format).