--- id: css-custom-fonts title: "CSS Custom Fonts" category: "Frontend" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["@font-face", "web fonts", "CSS custom fonts", "font-face rule", "WOFF fonts"] 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", "font-face", "typography"] raw_sources: ["https://www.w3schools.com/css/css3_fonts.asp"] applied_in: [] github_commit: "" --- # [[CSS Custom Fonts]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) The CSS `@font-face` rule lets you define and load custom (web) fonts so a page can use a typeface without it being installed on the visitor's computer β€” the font file downloads automatically when needed. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **`@font-face` defines and loads custom fonts** β€” it allows you to define and load custom fonts for use on a webpage. [S1] - **No local installation required** β€” the font does not need to be installed on the user's computer; it downloads automatically when needed. [S1] - **Two required descriptors** β€” `font-family` (the font name you choose) and `src` (the URL of the font file). [S1] - **Weight variants need their own rule** β€” to support bold, define an additional `@font-face` rule with `font-weight: bold;` pointing at the bold font file. [S1] - **Web-optimized formats exist** β€” WOFF and WOFF2 (Web Open Font Format) are optimized for web use and broadly supported; TTF/OTF are popular for desktop but are not web-optimized. [S1] ## 🧩 μΆ”μΆœλœ νŒ¨ν„΄ (Extracted patterns) - **Define-then-use pattern** β€” declare a font with `@font-face { font-family; src; }`, then reference that name in a selector's `font-family`. [S1] - **Weight-variant pattern** β€” add a second `@font-face` with `font-weight: bold;` and a bold font file. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) **The CSS `@font-face` Rule** [S1] The CSS `@font-face` rule allows you to define and load custom fonts for use on a webpage. The font does not need to be installed on the user's computer; it downloads automatically when needed. **Basic custom font example** [S1] In the `@font-face` rule, first define a name for the font (e.g. `myFont`) and then point to the font file. To use the font for an HTML element, refer to the font name through the `font-family` property: ```css @font-face { font-family: myFont; src: url(sansation_light.woff); } p { font-family: myFont; } ``` **Using bold text with `@font-face`** [S1] You must add another `@font-face` rule containing descriptors for bold text. The `src` property points to a different (bold) font file, and `font-weight: bold;` ties it to bold usage: ```css @font-face { font-family: myFont; src: url(sansation_bold.woff); font-weight: bold; } ``` This way the browser uses the specific bold font file whenever bold text of `myFont` is requested. **Font formats** [S1] - **WOFF / WOFF2 (Web Open Font Format)** β€” optimize file size for web use, developed in 2009, have W3C Recommendation status, and are supported across all major browsers. - **TTF (TrueType Fonts)** β€” emerged in the late 1980s via Apple; popular for desktop use but not web-optimized. - **OTF (OpenType Fonts)** β€” developed by Apple and Microsoft as an advanced, scalable format; popular for desktop use but not web-optimized. **CSS `@font-face` Descriptors table** [S1] | Descriptor | Description | |---|---| | `font-family` | Required; defines the font name | | `src` | Required; defines the URL of the font file | | `font-stretch` | Optional; default `normal` | | `font-style` | Optional; default `normal` | | `font-weight` | Optional; default `normal` | | `font-display` | Optional; default `auto` | | `unicode-range` | Optional; default `U+0-10FFFF` | ## πŸ› οΈ 적용 사둀 (Applied in summary) The page's own demonstrations (defining `myFont` via `@font-face` and applying it to `p`, plus the bold variant) serve as the applied examples. No external project/commit applications found in the source. ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Define and use a custom font (language: CSS): ```css @font-face { font-family: myFont; src: url(sansation_light.woff); } p { font-family: myFont; } ``` Add a bold variant: ```css @font-face { font-family: myFont; src: url(sansation_bold.woff); font-weight: bold; } ``` ## βš–οΈ 비ꡐ 및 선택 κΈ°μ€€ (Comparison & decision criteria) - **WOFF/WOFF2 vs TTF/OTF** β€” WOFF and WOFF2 are optimized for the web (smaller files, W3C Recommendation, broad browser support); TTF and OTF are popular for desktop use but are not web-optimized. Prefer WOFF/WOFF2 for the `src` of web fonts. [S1] - **Regular vs bold** β€” a single `@font-face` covers the regular weight; declare a separate `@font-face` with `font-weight: bold;` to load a dedicated bold file. [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 Text Effects]], [[CSS Text Shadow Effects]], [[CSS Box Shadow]] - **μ°Έμ‘° λ§₯락:** Referenced when loading a brand or non-system typeface so it renders consistently regardless of the visitor's installed fonts. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” CSS Custom Fonts β€” https://www.w3schools.com/css/css3_fonts.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-06-23: Initial draft synthesized from the W3Schools "CSS Custom Fonts" page (Astra wiki-curation, P-Reinforce v3.1 format).