Home > Article > Web Front-end > How Can I Import Multiple Font Weights with a Single @font-face Declaration?
Querying Multiple Font Weights with a Single @font-face Declaration
Importing multiple font variants with different weights can be tedious when relying on individual @font-face blocks. CSS offers a solution that combines these variants into a single declaration.
Implementing a Single @font-face Query
The key to achieving this is the specific syntax of the @font-face declaration, which accepts a colon-separated list of font weight, font style, and font family properties. Here's an example:
@font-face { font-family: "Klavika"; src: url("Klavika-Bold.otf") weight:bold, url("Klavika-Light.otf") weight:light; }
By specifying the weight, style, and family properties in this manner, multiple font variants can be imported simultaneously.
Example Usage
This method allows for flexible styling with individual font weights:
h1 { font-weight:bold; font-family: Klavika; } p { font-weight:light; font-family: Klavika; }
Additionally, you can leverage the standard @font-face syntax to specify other font properties, such as src and format.
Further Reading
For an exhaustive exploration of this feature, refer to the provided online resource, which offers a more detailed exposition and additional examples.
The above is the detailed content of How Can I Import Multiple Font Weights with a Single @font-face Declaration?. For more information, please follow other related articles on the PHP Chinese website!