Home > Web Front-end > CSS Tutorial > Can I Import Multiple Font Weights with a Single @font-face Query?

Can I Import Multiple Font Weights with a Single @font-face Query?

Mary-Kate Olsen
Release: 2024-11-15 05:04:02
Original
315 people have browsed it

Can I Import Multiple Font Weights with a Single @font-face Query?

Querying Multiple Font Weights with @font-face

In the situation where multiple font variations are available with varying weight and styles, such as the Klavika font mentioned, it is natural to inquire if it is possible to consolidate these imports into a single @font-face query to avoid repetitive copying.

The answer lies in a specialized form of @font-face that allows you to define weight within the query itself.

For instance, to import the Klavika family with various weights and styles, you can utilize the following:

@font-face {
  font-family: "Klavika";
  src: url("Klavika-Regular.otf") format("truetype") weight:normal;
  src: url("Klavika-Bold.otf") format("truetype") weight:bold;
  src: url("Klavika-Regular-Italic.otf") format("truetype") weight:normal style:italic;
  src: url("Klavika-Bold-Italic.otf") format("truetype") weight:bold style:italic;
}
Copy after login

This approach grants the ability to specify font-weight or font-style for any element without the need to explicitly declare the font-family or override previously set font weight and style. For example:

body { font-family:"Klavika", Georgia, serif; }

h1 { font-weight:bold; }

em { font-style:italic; }

strong em {
  font-weight:bold;
  font-style:italic;
}
Copy after login

The above is the detailed content of Can I Import Multiple Font Weights with a Single @font-face Query?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template