--- id: css-font-size title: "CSS Font Size" category: "Frontend" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["font-size", "CSS font size", "px em rem", "viewport font size", "responsive text size"] duplicate_of: "" source_trust_level: "B" confidence_score: 0.87 created_at: 2026-06-23 updated_at: 2026-06-23 review_reason: "" merge_history: [] tags: ["css", "web", "frontend", "w3schools", "fonts", "typography"] raw_sources: ["https://www.w3schools.com/css/css_font_size.asp"] applied_in: [] github_commit: "" --- # [[CSS Font Size]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) The `font-size` property sets text size using absolute units (px, keywords) or relative units (em, rem, %, vw); use px for fixed control, em/rem for scalable accessible designs, and rem for consistency since it always refers to the root `` font size. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **`font-size` property** β€” used to specify the size of the text/font; the page emphasizes proper semantic HTML usage for headings and paragraphs. [S1] - **Absolute sizes** β€” `px` (pixels) for fixed, precise control, plus keyword sizes: `xx-small`, `x-small`, `small`, `medium`, `large`, `x-large`, `xx-large`. [S1] - **Relative sizes** β€” `em` (relative to the parent element's font size), `rem` (relative to the root `` element's font size), `%` (relative to the parent), and `smaller`/`larger` (relative to the parent). [S1] - **`rem` consistency** β€” `rem` always refers to the font-size of the `` element, regardless of its position in the document tree, making it superior to `em` for consistency. [S1] ## 🧩 μΆ”μΆœλœ νŒ¨ν„΄ (Extracted patterns) - **Pixel scale** β€” fixed sizing per element (e.g. h1 40px, h2 30px, p 16px). [S1] - **Multiplier base** β€” set a base size on `body`/`html` (16px) and express element sizes as em/rem multipliers (2.5em β‰ˆ 40px, 1.875em β‰ˆ 30px, 1em β‰ˆ 16px). [S1] - **Viewport scaling** β€” use `vw` so text scales with the browser window size. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) The CSS `font-size` property is used to specify the size of the text/font, emphasizing proper semantic HTML usage for headings and paragraphs. [S1] **Unit types** [S1] - **Absolute sizes:** `px` (pixels) offer fixed, precise control; keyword sizes are `xx-small`, `x-small`, `small`, `medium`, `large`, `x-large`, `xx-large`. - **Relative sizes:** `em` (relative to parent's font size), `rem` (relative to root `` font size), `%` (relative to parent), and `smaller`/`larger` (adjust relative to parent). **Selection guidance** β€” use `px` for fixed control (though not ideal for responsive design); employ `em` or `rem` for scalable, accessible designs; apply `%` for parent-based adjustments. [S1] **Pixels approach** β€” h1 at 40px, h2 at 30px, p at 16px. [S1] ```css h1 { font-size: 40px; } h2 { font-size: 30px; } p { font-size: 16px; } ``` **Em approach** β€” body base 16px; h1 at 2.5em (40px); h2 at 1.875em (30px); p at 1em (16px). [S1] ```css body { font-size: 16px; } h1 { font-size: 2.5em; } h2 { font-size: 1.875em; } p { font-size: 1em; } ``` **Rem approach** β€” html set to 16px; same multipliers as the em approach. [S1] ```css html { font-size: 16px; } h1 { font-size: 2.5rem; } h2 { font-size: 1.875rem; } p { font-size: 1rem; } ``` **Viewport width (vw)** β€” h1 at 10vw; p at 5vw, scaling with browser window resizing. [S1] ```css h1 { font-size: 10vw; } p { font-size: 5vw; } ``` **Key concept:** `rem` always refers to the font-size of the `` element, regardless of its position in the document tree, making it superior to `em` for consistency. [S1] ## πŸ› οΈ 적용 사둀 (Applied in summary) The page's examples apply font-size with four unit strategies (px, em, rem, vw) to headings and paragraphs, demonstrating fixed vs. relative vs. viewport-based sizing. No external project/commit applications found in the source. ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Multiplier base pattern (language: CSS): ```css html { font-size: 16px; } h1 { font-size: 2.5rem; } ``` Viewport scaling pattern: ```css h1 { font-size: 10vw; } ``` ## βš–οΈ 비ꡐ 및 선택 κΈ°μ€€ (Comparison & decision criteria) - **px** β€” fixed, precise control; not ideal for responsive design. [S1] - **em** β€” relative to the parent's font size; can compound through nesting. [S1] - **rem** β€” relative to the root `` font size; preferred for consistency because it ignores position in the document tree. [S1] - **%** β€” relative to the parent; good for parent-based adjustments. [S1] - **vw** β€” scales with browser window size for fluid/responsive text. [S1] Guidance: use px for fixed control, em or rem for scalable accessible designs, and % for parent-based adjustments. [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.87 - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— 지식 κ·Έλž˜ν”„ (Knowledge Graph) - **μƒμœ„/루트:** [[CSS Tutorial]] - **κ΄€λ ¨ κ°œλ…:** [[CSS Font Family]], [[CSS Font Style]], [[CSS Units]] - **μ°Έμ‘° λ§₯락:** Referenced whenever setting readable, accessible, or responsive text sizing. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” CSS Font Size β€” https://www.w3schools.com/css/css_font_size.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-06-23: Initial draft synthesized from the W3Schools "CSS Font Size" page (Astra wiki-curation, P-Reinforce v3.1 format).