此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

font-family

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨2015年7月⁩.

font-family CSS 描述符为 @font-face At 规则中指定的字体设置字体族。

该值用于在使用 font-family 属性对元素进行样式设置时,与特定的 @font-face 名称进行匹配。可以使用任何名称,并且该名称会覆盖底层字体数据中指定的任何名称。

语法

css
/* <string> 值 */
font-family: "font family";
font-family: "another font family";

/* <custom-ident> 值 */
font-family: example-font;

<family-name>

指定字体族的名称。

形式定义

Related at-rule@font-face
初始值n/a (required)
计算值as specified

形式语法

font-family = 
<family-name>

<family-name> =
<string> |
<custom-ident>+

示例

设置字体族

css
@font-face {
  font-family: "字体族名称";
  src: url("some_font_name.ttf");
}

规范

Specification
CSS Fonts Module Level 4
# font-family-desc

浏览器兼容性

参见