Home > Web Front-end > CSS Tutorial > Can You Define Multiple Font Weights in a Single @font-face Query?

Can You Define Multiple Font Weights in a Single @font-face Query?

Susan Sarandon
Release: 2024-11-24 05:06:14
Original
620 people have browsed it

Can You Define Multiple Font Weights in a Single @font-face Query?

Can Multiple Font Weights Be Defined with a Single @font-face Query?

The Klavika font comes in various weights and shapes. Can these be imported into CSS with a single @font-face query that specifies the weight?

Solution:

Introducing a versatile feature of @font-face, you can associate different styles and weights with a single font family name:

@font-face {
  font-family: "DroidSerif";
  src: url("DroidSerif-Regular-webfont.ttf") format("truetype");  /* Normal weight, normal style */
  src: url("DroidSerif-Italic-webfont.ttf") format("truetype"); /* Normal weight, italic style */
  src: url("DroidSerif-Bold-webfont.ttf") format("truetype");  /* Bold weight, normal style */
  src: url("DroidSerif-BoldItalic-webfont.ttf") format("truetype"); /* Bold weight, italic style */
}
Copy after login

You can now specify font-weight:bold or font-style:italic for different elements:

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

h1 { font-weight:bold; }

em { font-style:italic; }

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

For comprehensive details on this feature, refer to the official documentation.

Example:

[Example Pen](https://codepen.io/anon/pen/EjxVqv)

The above is the detailed content of Can You Define Multiple Font Weights in 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