@font-face Generator

Generate a complete, correct CSS @font-face rule for any web font. Configure family name, WOFF2/WOFF source URLs, weight range, style, display strategy, and unicode-range. Copy the output directly into your stylesheet.

How to use the @font-face generator

  1. Enter the font family name — this is what you will reference in CSS.
  2. Paste the URL of your WOFF2 file. Add WOFF as fallback if supporting very old browsers.
  3. Set the weight. Use a single value for static fonts (400) or a range for variable fonts (100 900).
  4. Choose a font-display strategy. swap is the default for body text.
  5. Copy the generated CSS into your stylesheet or a dedicated fonts.css file.

Understanding the @font-face properties

PropertyPurposeRecommended value
font-familyName to reference in CSSMatch your design system name
srcFont file URLsWOFF2 first, WOFF second (optional)
font-weightWeight the file covers400 for static, 100 900 for variable
font-styleNormal, italic, or obliquenormal
font-displayLoading behaviourswap for body, optional for zero CLS
unicode-rangeLimit to specific charactersOptional — useful for subsetting
Performance tip: If you only ship WOFF2 (all browsers after 2016 support it), your CSS is smaller and users download fewer bytes. Ship a WOFF fallback only when explicitly required by your browser support matrix.

Frequently asked questions

What is @font-face in CSS?

It is a CSS rule that loads a font file and maps it to a family name. Once declared, you reference the family with font-family anywhere in your CSS.

Should I include both WOFF2 and WOFF sources?

WOFF2 alone is sufficient for all browsers released after 2016. Include WOFF only if supporting older browsers — most production projects do not need it.

What is font-weight: 100 900?

That is a weight range declaration for variable fonts. It tells the browser the single font file covers the full weight spectrum, avoiding synthesised bold.

Do I need unicode-range?

Only if you are subsetting a font to specific characters. For most projects, leave it empty and the font will apply to all characters it contains.

What does font-display do?

It controls how the browser handles the gap between page paint and font load. swap renders fallback immediately and swaps when ready. block hides text. fallback and optional are middle-ground strategies.

Related tools