CSS font-feature-settings
The font-feature-settings
property gives you low-level control over OpenType font features.
The font-feature-settings
property is one of the properties introduced in CSS3 for enabling various font related features that can improve the appearance of the text on the page. The font-feature-settings
property was specifically intended as a way of providing access to font features that are not widely used but are needed for a particular use case.
Syntax
The syntax of the font-feature-settings
property is:
Where
These values are explained in more detail below.
Possible Values
normal
- Specifies that that no change in glyph selection or positioning occurs due to this property.
- string
- This value specifies a case-sensitive OpenType feature tag (OpenType feature tags contain four ASCII characters). The value must be a valid string of four ASCII characters and be within the U+20-7E codepoint range.
- integer
-
This is an optional value that can be used for glyph selection. It must be a valid integer of
0
or more.If the value is
0
, the feature is disabled. If used on a boolean feature, a value of1
enables the feature. When used on non-boolean features, a value of1
or greater enables the feature and indicates the feature selection index.If this value is omitted, a value of
1
is assumed. on
- Synonymous with
1
. off
- Synonymous with
0
.
In addition, all CSS properties also accept the following CSS-wide keyword values as the sole component of their property value:
initial
- Represents the value specified as the property's initial value.
inherit
- Represents the computed value of the property on the element's parent.
unset
- This value acts as either
inherit
orinitial
, depending on whether the property is inherited or not. In other words, it sets all properties to their parent value if they are inheritable or to their initial value if not inheritable.
General Information
- Initial Value
normal
- Applies To
- All elements
- Inherited?
- Yes
- Media
- Visual
- Animatable?
- No
Example Code
Official Specifications
- CSS Fonts Module Level 3 (W3C Candidate Recommendation 3 October 2013)
Vendor Prefixes
For maximum browser compatibility many web developers add browser-specific properties by using extensions such as -webkit-
for Safari, Google Chrome, and Opera (newer versions), -ms-
for Internet Explorer, -moz-
for Firefox, -o-
for older versions of Opera etc. As with any CSS property, if a browser doesn't support a proprietary extension, it will simply ignore it.
This practice is not recommended by the W3C, however in many cases, the only way you can test a property is to include the CSS extension that is compatible with your browser.
The major browser manufacturers generally strive to adhere to the W3C specifications, and when they support a non-prefixed property, they typically remove the prefixed version. Also, W3C advises vendors to remove their prefixes for properties that reach Candidate Recommendation status.
Many developers use Autoprefixer, which is a postprocessor for CSS. Autoprefixer automatically adds vendor prefixes to your CSS so that you don't need to. It also removes old, unnecessary prefixes from your CSS.
You can also use Autoprefixer with preprocessors such as Less and Sass.