--- id: css-units title: "CSS Units" category: "Frontend" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["CSS units", "CSS length", "length values", "absolute units", "relative units"] 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", "units", "length", "measurement"] raw_sources: ["https://www.w3schools.com/css/css_units.asp"] applied_in: [] github_commit: "" --- # [[CSS Units]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) CSS units express the length of properties such as `font-size`, `width`, `margin`, `padding`, and `border`, and they split into two families: absolute units (fixed) and relative units (scale with parent, root, or viewport). [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **Length values** β€” several CSS properties take "length" values, such as `font-size`, `width`, `margin`, `padding`, and `border`. [S1] - **No whitespace rule** β€” there must be no space between the number and the unit (e.g., `10px`, not `10 px`); however, if the value is `0`, the unit can be omitted. [S1] - **Two categories** β€” Absolute units are fixed lengths; Relative units scale based on a parent element, the root element, or the viewport. [S1] ## 🧩 μΆ”μΆœλœ νŒ¨ν„΄ (Extracted patterns) - **Absolute for print, relative for screen** β€” absolute units suit fixed/print contexts; relative units (`em`, `rem`) scale better across screen sizes. [S1] - **Omit unit only for zero** β€” `0` is the single value where the unit may be dropped. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) **Introduction** Several CSS properties take "length" values, such as `font-size`, `width`, `margin`, `padding`, and `border`. There must be no whitespace between the number and the unit; however, if the value is `0`, the unit can be omitted. [S1] CSS has two types of length units: **Absolute** and **Relative**. [S1] **Absolute Lengths** Absolute length units are fixed lengths. [S1] | Unit | Description | | --- | --- | | `cm` | centimeters [S1] | | `mm` | millimeters [S1] | | `in` | inches (1in = 96px = 2.54cm) [S1] | | `px` | pixels (1px = 1/96th of 1in) β€” the most-used absolute unit for screens [S1] | | `pt` | points (1pt = 1/72 of 1in) β€” a typographical unit [S1] | | `pc` | picas (1pc = 12 pt) β€” a print unit [S1] | A typical absolute-unit usage sets font sizes in pixels: [S1] ```css h1 { font-size: 40px; } h2 { font-size: 30px; } p { font-size: 17px; } ``` **Relative Lengths** Relative length units specify a length relative to another length property, and scale better between different screen sizes. [S1] | Unit | Description | | --- | --- | | `em` | Relative to the font-size of the element [S1] | | `ex` | Relative to the x-height of the current font (height of lowercase "x") [S1] | | `ch` | Relative to the width of the "0" (zero) character [S1] | | `rem` | Relative to the font-size of the root element [S1] | | `vw` | Relative to 1% of the width of the viewport [S1] | | `vh` | Relative to 1% of the height of the viewport [S1] | | `vmin` | Relative to 1% of the viewport's smaller dimension [S1] | | `vmax` | Relative to 1% of the viewport's larger dimension [S1] | | `%` | Relative to the size of the parent element [S1] | **Tip:** The `em` and `rem` units are perfect for creating scalable and responsive websites. [S1] ## πŸ› οΈ 적용 사둀 (Applied in summary) The page's applied case is the pixel font-size example styling `h1`, `h2`, and `p`. Detailed per-family examples live on the dedicated [[CSS Absolute Units]] and [[CSS Relative Units]] pages. No external project/commit applications found in the source. ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Pixel (absolute) font sizing (language: CSS): ```css h1 { font-size: 40px; } p { font-size: 17px; } ``` ## βš–οΈ 비ꡐ 및 선택 κΈ°μ€€ (Comparison & decision criteria) - **Absolute units** (`cm`, `mm`, `in`, `px`, `pt`, `pc`) β€” fixed lengths; pixels are the most-used for screens, the rest are mainly for print. [S1] - **Relative units** (`em`, `ex`, `ch`, `rem`, `vw`, `vh`, `vmin`, `vmax`, `%`) β€” scale relative to another length, so they adapt across screen sizes; `em` and `rem` are recommended for scalable, responsive sites. [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 Absolute Units]], [[CSS Relative Units]], [[CSS Font Size]] - **μ°Έμ‘° λ§₯락:** Referenced whenever specifying any length value (size, spacing, borders) in CSS. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” CSS Units β€” https://www.w3schools.com/css/css_units.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-06-23: Initial draft synthesized from the W3Schools "CSS Units" page (Astra wiki-curation, P-Reinforce v3.1 format).