docs.rodeo

MDN Web Docs mirror

CSS fonts

{{CSSRef}} 

The CSS fonts module defines font-related properties and how font resources are loaded. It lets you define the style of a font, such as its family, size and weight, and the glyph variants to use when multiple are available for a single character.

A font is a resource file containing the visual representation of characters, mapping character codes to glyphs that represent letters, numbers, punctuation and even emojis of a typeface. A font family is a group of fonts that share common design styles and font properties, with each member of the group providing different ways of displaying the glyphs, varying by stroke weight, slant, or relative width, among other attributes. A font typically represents a single style of a typeface, such as Helvetica that is Bold and Italic. A font family is the complete set of styles. Including such a font in a document or design is done by defining a separate @font-face declaration for each font resource.

The properties, at-rules, and descriptors of the CSS fonts module enable the downloading of multiple variations of a font. They also define the font file to use for a particular font characteristic, along with fallback instructions in case a resource fails to load. The CSS font selection mechanism describes the process of matching a given set of CSS font properties to a single font face.

The CSS fonts module also supports variable fonts. Unlike regular fonts, where each style is implemented as a separate font file, variable fonts can contain all styles within a single file. By using a single @font-face declaration, you can import a variable font that includes all the styles. Depending on the font, this can include a multitude of font variants. Variable fonts are a part of the OpenType font specification.

Reference

Properties

The specification also defines the font-width property, which is not yet supported by any browser.

At-rules and descriptors

The specification also defines the font-language-override, font-named-instance, font-width, font-size, subscript-position-override, subscript-size-override, superscript-position-override, and superscript-size-override descriptors, which are not yet supported by any browser.

Data types

font-size types:

font-family type:

font-feature-settings type:

font-format type:

font-stretch type:

font-tech types:

font-variant types:

font-variant-ligatures types:

font-variant-numeric types:

font-weight type:

Interfaces

Guides

Specifications

{{Specifications}} 

See also

In this article

View on MDN