Path: blob/main/files/en-us/web/css/@font-palette-values/font-family/index.md
6579 views
------{{CSSRef}}
The @font-palette-values descriptor font-family is used to specify which font-family palette values are to be applied to. This need to match exactly the values used when setting the CSS font-family.
Syntax
Other palette values that follow apply only to the specified font family. You can create @font-palette-values for other font families by using the same <dashed-ident>s. This means that if you have multiple Color Fonts and can use the same identifier for each.
Values
<family-name>: Specifies the name of the font-family.
Formal definition
{{cssinfo}}
Formal syntax
{{csssyntax}}
Examples
Using matching family names
In this example, when the font-family descriptor is used in the @font-palette-values at-rule, the same value is used for the font-family, as when it is declared.
HTML
CSS
Result
{{EmbedLiveSample("Using matching family names")}}
Using the same palette identifier for multiple font-families
In this example, two @font-palette-values at-rules are set for two font families, but both the at-rules use the same dashed-ident identifier, --Dark Mode. This helps to set the font-palette property for multiple elements, h1 and h2 in this case, at the same time. This can be useful when you want to update font colors to match your site's branding.
Specifications
{{Specifications}}
Browser compatibility
{{Compat}}
See also
{{cssxref("@font-face/font-family", "font-family")}}
{{cssxref("@font-palette-values/", "@font-palette-values")}}
{{cssxref("@font-palette-values/font-family", "font-family")}} descriptor
{{cssxref("@font-palette-values/override-colors", "override-colors")}} descriptor
{{cssxref("font-palette/", "font-palette")}} property