--- id: css-math-functions title: "CSS Math Functions" category: "Frontend" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["calc()", "min()", "max()", "clamp()", "CSS calc", "responsive sizing functions"] duplicate_of: "" source_trust_level: "B" confidence_score: 0.9 created_at: 2026-06-23 updated_at: 2026-06-23 review_reason: "" merge_history: [] tags: ["css", "web", "frontend", "w3schools", "math-functions", "calc", "responsive"] raw_sources: ["https://www.w3schools.com/css/css_math_functions.asp"] applied_in: [] github_commit: "" --- # [[CSS Math Functions]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) CSS math functions β€” `calc()`, `max()`, `min()`, and `clamp()` β€” let property values be computed (and mixed across units) at render time, enabling responsive sizing without JavaScript. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **`calc()`** β€” performs a mathematical calculation that will be used as the property value, supporting mixed units. [S1] - **`max()`** β€” takes a comma-separated list of values and uses the largest value from the list as the property value. [S1] - **`min()`** β€” takes a comma-separated list of values and uses the smallest value from the list as the property value. [S1] - **`clamp()`** β€” sets a value that adjusts responsively between a minimum, a preferred, and a maximum value depending on the size of the viewport. [S1] ## 🧩 μΆ”μΆœλœ νŒ¨ν„΄ (Extracted patterns) - **Mixed-unit arithmetic** β€” `calc()` combines incompatible units such as `%`, `px`, and `vh` in one expression (e.g. `calc(100% - 100px)`). [S1] - **Responsive clamp pattern** β€” `clamp(min, preferred, max)` with a viewport-relative preferred value (e.g. `clamp(1.5rem, 5vw, 3rem)`) produces fluid typography and widths bounded at both ends. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) **`calc()` β€” perform a calculation.** The `calc()` function performs a mathematical calculation that will be used as the property value. It supports addition, subtraction, multiplication, and division with mixed units. [S1] ```css #div1 { margin: auto; width: calc(100% - 100px); height: calc(30vh + 50px); border: 1px solid black; padding: 10px; } ``` **`max()` β€” use the largest value.** The `max()` function takes a comma-separated list of values, and uses the largest value from the list as the property value. [S1] ```css #div1 { height: 100px; width: max(50%, 300px); border: 1px solid black; padding: 10px; } ``` **`min()` β€” use the smallest value.** The `min()` function takes a comma-separated list of values, and uses the smallest value from the list as the property value. [S1] ```css #div1 { height: 100px; width: min(50%, 300px); border: 1px solid black; padding: 10px; } ``` **`clamp()` β€” responsive bounded value.** The `clamp()` function is used to set a value that will adjust responsively between a minimum value, a preferred value, and a maximum value depending on the size of the viewport. [S1] ```css h2 { font-size: clamp(1.5rem, 5vw, 3rem); } div { border: 1px solid green; padding: 10px; font-size: clamp(1rem, 2.5vw, 2rem); width: clamp(200px, 50%, 600px); } ``` ## πŸ› οΈ 적용 사둀 (Applied in summary) The page's applied demonstrations style a `#div1` box (and a `clamp()`-based heading/div pair) to show each function computing a live property value β€” for example a width that is the viewport minus 100px, or a font-size that scales with `5vw` but never below `1.5rem` or above `3rem`. No external project/commit applications found in the source. ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Mixed-unit calculation (language: CSS): ```css width: calc(100% - 100px); height: calc(30vh + 50px); ``` Clamp for fluid, bounded sizing (language: CSS): ```css font-size: clamp(1.5rem, 5vw, 3rem); width: clamp(200px, 50%, 600px); ``` ## βš–οΈ 비ꡐ 및 선택 κΈ°μ€€ (Comparison & decision criteria) - **`calc()`** β€” when you need an exact arithmetic expression mixing units (e.g. fill the viewport minus a fixed sidebar). [S1] - **`max()`** β€” when you want a floor: never smaller than the largest of the listed values. [S1] - **`min()`** β€” when you want a ceiling: never larger than the smallest of the listed values. [S1] - **`clamp()`** β€” when you want both a floor and a ceiling around a fluid preferred value in one declaration. [S1] ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (Contradictions & updates) No contradictions found in the source. (Note: the source page spells "preferred" as "preffered" in its `clamp()` description; corrected here.) [S1] ## βœ… 검증 μƒνƒœ 및 신뒰도 - **μƒνƒœ:** draft - **검증 단계:** conceptual (μ‹€μ œ 적용 사둀 발견 μ‹œ applied/validated둜 승격 κ°€λŠ₯) - **좜처 신뒰도:** B (W3Schools β€” widely used educational reference, not a primary standards body) - **μ‹ λ’° 점수:** 0.9 - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— 지식 κ·Έλž˜ν”„ (Knowledge Graph) - **μƒμœ„/루트:** [[CSS Tutorial]] - **κ΄€λ ¨ κ°œλ…:** [[CSS Units]], [[CSS Website Layout]], [[CSS Optimization]] - **μ°Έμ‘° λ§₯락:** Used whenever a property value must be computed or made responsive across viewport sizes without scripting. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” CSS Math Functions β€” https://www.w3schools.com/css/css_math_functions.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-06-23: Initial draft synthesized from the W3Schools "CSS Math Functions" page (Astra wiki-curation, P-Reinforce v3.1 format).