font-feature-settings
CSS property controls advanced typographic features in OpenType fonts.
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
/* Use the default settings */ font-feature-settings: normal; /* Set values for OpenType feature tags */ font-feature-settings: "smcp"; font-feature-settings: "smcp" on; font-feature-settings: "swsh" 2; font-feature-settings: "smcp", "swsh" 2; /* Global values */ font-feature-settings: inherit; font-feature-settings: initial; font-feature-settings: unset;Whenever possible, Web authors should instead use the
font-variant
shorthand property or an associated longhand property such as
font-variant-ligatures
,
font-variant-caps
,
font-variant-east-asian
,
font-variant-alternates
,
font-variant-numeric
or
font-variant-position
.
font-feature-settings
, which is a low-level feature designed to handle special cases where no other way exists to enable or access an OpenType font feature. In particular,
font-feature-settings
shouldn't be used to enable small caps.
normal
Text is laid out using default settings.
<feature-tag-value>
<string>
of 4 ASCII characters. If it has more or less characters, or if it contains characters outside the
U+20
–
U+7E
codepoint range, the whole property is invalid.
on
and
off
are synonyms for
1
and
0
respectively. If no value is set, the default is
1
. For non-Boolean OpenType features (e.g.
stylistic alternates
), the value implies a particular glyph to be selected; for Boolean values, it is a switch.
| 初始值 |
normal
|
|---|---|
| 适用于 |
所有元素。它还适用于
::first-letter
and
::first-line
.
|
| 继承 | yes |
| 计算值 | 如指定 |
| 动画类型 | discrete |
normal | <feature-tag-value>#where
<feature-tag-value> = <string> [ <integer> | on | off ]?
/* use small-cap alternate glyphs */
.smallcaps { font-feature-settings: "smcp" on; }
/* convert both upper and lowercase to small caps (affects punctuation also) */
.allsmallcaps { font-feature-settings: "c2sc", "smcp"; }
/* use zeros with a slash through them to differentiate from "O" */
.nicezero { font-feature-settings: "zero"; }
/* enable historical forms */
.hist { font-feature-settings: "hist"; }
/* disable common ligatures, usually on by default */
.noligs { font-feature-settings: "liga" 0; }
/* enable tabular (monospaced) figures */
td.tabular { font-feature-settings: "tnum"; }
/* enable automatic fractions */
.fractions { font-feature-settings: "frac"; }
/* use the second available swash character */
.swash { font-feature-settings: "swsh" 2; }
/* enable stylistic set 7 */
.fancystyle {
font-family: Gabriola; /* available on Windows 7, and on Mac OS */
font-feature-settings: "ss07";
}
| 规范 | 状态 | 注释 |
|---|---|---|
|
CSS Fonts Module Level 3
The definition of 'font-feature-settings' in that specification. |
候选推荐 | 初始定义 |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
font-feature-settings
|
Chrome 完整支持 48 | Edge 完整支持 15 |
Firefox
完整支持
34
注意事项
|
IE 完整支持 10 | Opera 完整支持 35 |
Safari
完整支持
9.1
|
WebView Android 完整支持 4.4 | Chrome Android 完整支持 48 |
Firefox Android
完整支持
34
注意事项
|
Opera Android 完整支持 35 |
Safari iOS
完整支持
9.3
|
Samsung Internet Android 完整支持 5.0 |
完整支持
见实现注意事项。
要求使用供应商前缀或不同名称。
font-display
font-family
font-stretch
font-style
font-weight
font-variant
font-variation-settings
src
unicode-range
-moz
syntax is the old one. On Gecko, use the
-ms
syntax but with
-moz
.)
font
font-family
font-feature-settings
font-kerning
font-language-override
font-optical-sizing
font-size
font-size-adjust
font-smooth
font-stretch
font-style
font-synthesis
font-variant
font-variant-alternates
font-variant-caps
font-variant-east-asian
font-variant-ligatures
font-variant-numeric
font-variant-position
font-variation-settings
font-weight
line-height
line-height-step