font-feature-settings

  • Revision slug: CSS/font-feature-settings
  • Revision title: font-feature-settings
  • Revision id: 356739
  • Created:
  • Creator: ethertank
  • Is current revision? No
  • Comment id ...etc.

Revision Content

{{CSSRef}}
{{SeeCompatTable}}

Summary

The font-feature-settings CSS property allows control over advanced typographic features in OpenType fonts.

Note: Whenever possible, Web authors should use the {{cssxref("font-variant")}} property. This property has been designed to handle special cases where no other way to enable or access an OpenType font feature does exists.

In particular, this CSS property shouldn't be used to enable small caps.
  • {{Xref_cssinitial}} {{Cssinitial("font-feature-settings")}}
  • Applies to all elements
  • {{Xref_cssinherited}} yes
  • Media {{Xref_cssvisual}}
  • {{Xref_csscomputed}} as specified

Syntax

Formal syntax: {{csssyntax("font-feature-settings")}}
font-feature-settings: normal
font-feature-settings: "smcp"
font-feature-settings: "smcp" on
font-feature-settings: "swsh" 2
font-feature-settings: "smcp", "swsh" 2

font-feature-settings: inherit

Values

normal
Text is laid out using default settings.
<feature-tag-value>
When rendering text, the list of OpenType feature tag value is passed to the text layout engine to enable or disable font features. The tag is always a {{xref_cssstring}} of 4 ASCII characters. If it has more or less characters or contains characters outside the U+20 - U+7E codepoint range, the whole property is invalid.
The value is an positive integer. The two keywords 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.

Examples

/* 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"; }

/* 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";
}

Specificat​ions

Specification Status Comment
{{SpecName('CSS3 Fonts', '#propdef-font-feature-settings', 'font-feature-settings')}} {{Spec2('CSS3 Fonts')}}  

Browser compatibility

{{CompatibilityTable}}
Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 16.0 {{property_prefix("-webkit")}} 4.0 (2.0) (See note){{property_prefix("-moz")}} 10.0 {{CompatNo}} {{CompatNo}}
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}

Browser notes

See also

Revision Source

<div>{{CSSRef}}</div>
<div>{{SeeCompatTable}}</div>
<h2 id="Summary">Summary</h2>
<p>The <code>font-feature-settings</code> CSS property allows control over advanced typographic features in OpenType fonts.</p>
<div class="note">
  <strong>Note:</strong> Whenever possible, Web authors should use the {{cssxref("font-variant")}} property. This property has been designed to handle special cases where no other way to enable or access an OpenType font feature does exists.<br />
  <br />
  In particular, this CSS property shouldn't be used to enable small caps.</div>
<ul class="cssprop">
  <li><dfn>{{Xref_cssinitial}}</dfn> {{Cssinitial("font-feature-settings")}}</li>
  <li><dfn>Applies to</dfn> all elements</li>
  <li><dfn>{{Xref_cssinherited}}</dfn> yes</li>
  <li><dfn>Media</dfn> {{Xref_cssvisual}}</li>
  <li><dfn>{{Xref_csscomputed}}</dfn> as specified</li>
</ul>
<h2 id="Syntax">Syntax</h2>
<pre class="twopartsyntaxbox">
<a href="/en-US/docs/CSS/Value_definition_syntax" title="CSS/Value_definition_syntax">Formal syntax</a>: {{csssyntax("font-feature-settings")}}
</pre>
<pre>
font-feature-settings: normal
font-feature-settings: "smcp"
font-feature-settings: "smcp" on
font-feature-settings: "swsh" 2
font-feature-settings: "smcp", "swsh" 2

font-feature-settings: inherit
</pre>
<h3 id="Values">Values</h3>
<dl>
  <dt><code>normal</code></dt>
  <dd>Text is laid out using default settings.</dd>
  <dt><code>&lt;feature-tag-value&gt;</code></dt>
  <dd>When rendering text, the list of OpenType feature tag value is passed to the text layout engine to enable or disable font features. The tag is always a {{xref_cssstring}} of 4 ASCII characters. If it has more or less characters or contains characters outside the U+20 - U+7E codepoint range, the whole property is invalid.<br />
    The value is an positive integer. The two keywords <code>on</code> and <code>off</code> are synonyms for <code>1</code> and <code>0</code> respectively. If no value is set, the default is <code>1</code>. For non-Boolean OpenType features (e.g. <a href="http://www.microsoft.com/typography/otspec/features_pt.htm#salt" title="http://www.microsoft.com/typography/otspec/features_pt.htm#salt">stylistic alternates</a>), the value implies a particular glyph to be selected; for Boolean values, it is a switch.</dd>
</dl>
<h2 id="Examples">Examples</h2>
<pre class="brush:css">
/* 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"; }

/* 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";
}
</pre>
<h2 id="Specificat.E2.80.8Bions">Specificat​ions</h2>
<table class="standard-table">
  <thead>
    <tr>
      <th scope="col">Specification</th>
      <th scope="col">Status</th>
      <th scope="col">Comment</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>{{SpecName('CSS3 Fonts', '#propdef-font-feature-settings', 'font-feature-settings')}}</td>
      <td>{{Spec2('CSS3 Fonts')}}</td>
      <td>&nbsp;</td>
    </tr>
  </tbody>
</table>
<h2 id="Browser_compatibility">Browser compatibility</h2>
<div>{{CompatibilityTable}}</div>
<div id="compat-desktop">
  <table class="compat-table">
    <tbody>
      <tr>
        <th>Feature</th>
        <th>Chrome</th>
        <th>Firefox (Gecko)</th>
        <th>Internet Explorer</th>
        <th>Opera</th>
        <th>Safari (WebKit)</th>
      </tr>
      <tr>
        <td>Basic support</td>
        <td>16.0&nbsp;{{property_prefix("-webkit")}}</td>
        <td>4.0 (2.0) (See <a href="/en-US/docs/CSS/font-feature-settings#B1" title="https://developer.mozilla.org/en/CSS/font-feature-settings#B1">note</a>){{property_prefix("-moz")}}</td>
        <td>10.0</td>
        <td>{{CompatNo}}</td>
        <td>{{CompatNo}}</td>
      </tr>
    </tbody>
  </table>
</div>
<div id="compat-mobile">
  <table class="compat-table">
    <tbody>
      <tr>
        <th>Feature</th>
        <th>Android</th>
        <th>Firefox Mobile (Gecko)</th>
        <th>IE Phone</th>
        <th>Opera Mobile</th>
        <th>Safari Mobile</th>
      </tr>
      <tr>
        <td>Basic support</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatUnknown}}</td>
      </tr>
    </tbody>
  </table>
</div>
<h3 id="Browser_notes">Browser notes</h3>
<ul>
  <li><a name="B1">From Gecko 2.0 (Firefox 4.0) to Gecko 14.0 (Firefox 14.0) inclued, Gecko supported an older syntax, slightly different from the modern one: </a><a href="http://hacks.mozilla.org/2010/11/firefox-4-font-feature-support/" title="http://hacks.mozilla.org/2010/11/firefox-4-font-feature-support/">OpenType Font Feature support in Firefox 4</a>.</li>
</ul>
<h2 id="See_also">See also</h2>
<ul>
  <li><a href="https://www.fontfont.com/staticcontent/downloads/FF_OT_User_Guide.pdf" title="http://www.fontfont.com/opentype/FF_OT_UserGuide_v2.pdf">FontFont OpenType User Guide (pdf)</a></li>
  <li><a href="http://www.microsoft.com/typography/otspec/featurelist.htm" title="http://www.microsoft.com/typography/otspec/featurelist.htm">OpenType Feature Tags</a>&nbsp;list</li>
  <li><a href="http://blogs.msdn.com/b/ie/archive/2012/01/09/css-corner-using-the-whole-font.aspx" title="http://blogs.msdn.com/b/ie/archive/2012/01/09/css-corner-using-the-whole-font.aspx">Using the whole font</a> (The -moz syntax is the old one. On Gecko, use the -ms syntax but with -moz).</li>
</ul>
Revert to this revision