text-rendering CSS property

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.

The text-rendering CSS property provides information to the rendering engine about what to optimize for when rendering text.

The browser makes trade-offs among speed, legibility, and geometric precision.

Note: The text-rendering property is an SVG property that is not defined in any CSS standard. However, Gecko and WebKit browsers let you apply this property to HTML and XML content on Windows, macOS, and Linux.

One very visible effect is optimizeLegibility, which enables ligatures (ff, fi, fl, etc.) in text smaller than 20px for some fonts (for example, Microsoft's Calibri, Candara, Constantia, and Corbel, or the DejaVu font family).

Syntax

css
/* Keyword values */
text-rendering: auto;
text-rendering: optimizeSpeed;
text-rendering: optimizeLegibility;
text-rendering: geometricPrecision;

/* Global values */
text-rendering: inherit;
text-rendering: initial;
text-rendering: revert;
text-rendering: revert-layer;
text-rendering: unset;

Values

auto

The browser makes educated guesses about when to optimize for speed, legibility, and geometric precision while drawing text. For differences in how this value is interpreted by the browser, see the compatibility table.

The auto value is a good default for balancing quality and performance, especially for extended bodies of plain text.

optimizeSpeed

The browser emphasizes rendering speed over legibility and geometric precision when drawing text. It disables kerning and ligatures.

The optimizeSpeed value is preferable in resource-constrained rendering scenarios, such as slow processors or low battery.

optimizeLegibility

The browser emphasizes legibility over rendering speed and geometric precision. This enables kerning and optional ligatures.

The optimizeLegibility value is preferable for texts that are large in size but short in content, such as headers or banners, to enhance their readability. It could also be used for high-quality professional typography such as published articles. It's not recommended for typical articles due to potential performance impacts.

geometricPrecision

The browser emphasizes geometric precision over rendering speed and legibility. Certain aspects of fonts — such as kerning — don't scale linearly. So this value can make text using those fonts look good.

In SVG, when text is scaled up or down, browsers calculate the final size of the text (which is determined by the specified font size and the applied scale) and request a font of that computed size from the platform's font system. But if you request a font size of, say, 9 with a scale of 140%, the resulting font size of 12.6 doesn't explicitly exist in the font system, so the browser rounds the font size to 12 instead. This results in stair-step scaling of text.

But the geometricPrecision property — when fully supported by the rendering engine — lets you scale your text fluidly. For large scale factors, you might see less-than-beautiful text rendering, but the size is what you would expect—neither rounded up nor down to the nearest font size supported by Windows or Linux.

The geometricPrecision value optimizes neither readability nor performance. It usually makes sense in SVG, where you want your graphic to scale faithfully without distorting the text dimensions.

Note: WebKit precisely applies the specified value, but Gecko treats the value the same as optimizeLegibility.

Formal definition

Initial valueauto
Applies totext elements
Inheritedyes
Computed valueas specified
Animation typediscrete

Formal syntax

text-rendering = 
auto |
optimizeSpeed |
optimizeLegibility |
geometricPrecision

Examples

Automatic application of optimizeLegibility

This demonstrates how optimizeLegibility is used by browsers automatically when the font-size is smaller than 20px.

HTML

html
<p class="small">LYoWAT - ff fi fl ffl</p>
<p class="big">LYoWAT - ff fi fl ffl</p>

CSS

css
.small {
  font:
    19.9px "Constantia",
    "Times New Roman",
    "Georgia",
    "Palatino",
    serif;
}
.big {
  font:
    20px "Constantia",
    "Times New Roman",
    "Georgia",
    "Palatino",
    serif;
}

Result

optimizeSpeed vs. optimizeLegibility

This example shows the difference between the appearance of optimizeSpeed and optimizeLegibility (in your browser; other browsers may vary).

HTML

html
<p class="speed">LYoWAT - ff fi fl ffl</p>
<p class="legibility">LYoWAT - ff fi fl ffl</p>

CSS

css
p {
  font:
    1.5em "Constantia",
    "Times New Roman",
    "Georgia",
    "Palatino",
    serif;
}

.speed {
  text-rendering: optimizeSpeed;
}
.legibility {
  text-rendering: optimizeLegibility;
}

Result

Specifications

Specification
Scalable Vector Graphics (SVG) 2
# TextRenderingProperty

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
text-rendering
Chrome – Full support
Chrome 4 (Release date: 2010-01-25)
footnote
footnote This property is only supported on Windows and Linux.
footnote Initial versions had bugs on Windows and Linux that broke font substitution, small-caps, letter-spacing or caused text to overlap. See bug 40156511, bug 40430936, bug 40444347, bug 40286561.
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote
footnote This property is only supported on Windows and Linux.
footnote Initial versions had bugs on Windows and Linux that broke font substitution, small-caps, letter-spacing or caused text to overlap. See bug 40156511, bug 40430936, bug 40444347, bug 40286561.
Firefox – Full support
Firefox 1 (Release date: 2004-11-09)
footnote
footnote This property is only supported on Windows and Linux.
footnote The optimizeSpeed option has no effect on Firefox 4 because the standard code for text rendering is already fast and there is not a faster code path at this time. See bug 595688 for details.
Opera – Full support
Opera 15 (Release date: 2013-07-02)
footnote Full support
Safari – Full support
Safari 5 (Release date: 2010-06-07)
footnote Full support
Chrome Android – Full support
Chrome Android 18 (Release date: 2012-06-27)
footnote
footnote This property is only supported on Windows and Linux.
footnote Initial versions had bugs on Windows and Linux that broke font substitution, small-caps, letter-spacing or caused text to overlap. See bug 40156511, bug 40430936, bug 40444347, bug 40286561.
Firefox for Android – Full support
Firefox for Android 46 (Release date: 2016-04-26)
footnote Full support
Opera Android – Full support
Opera Android 14 (Release date: 2013-05-21)
footnote Full support
Safari on iOS – Full support
Safari on iOS 4.2 (Release date: 2010-11-22)
footnote Full support
Samsung Internet – Full support
Samsung Internet 1 (Release date: 2013-04-27)
footnote
footnote This property is only supported on Windows and Linux. Samsung Internet is not on Windows or Linux.
WebView Android – Full support
WebView Android 3 (Release date: 2011-02-22)
footnote
footnote From version 3 to 4.3, there is a serious bug where text-rendering: optimizeLegibility causes custom web fonts to not render. This was fixed in version 4.4.
WebView on iOS – Full support
WebView on iOS 4.2 (Release date: 2010-11-22)
footnote Full support
auto
Chrome – Full support
Chrome 4 (Release date: 2010-01-25)
footnote
footnote Chrome treats auto as optimizeSpeed.
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote
footnote Edge treats auto as optimizeSpeed.
Firefox – Full support
Firefox 1 (Release date: 2004-11-09)
footnote
footnote If the font size is 20 pixels or higher, Firefox treats auto as optimizeLegibility. For smaller text, Firefox treats auto as optimizeSpeed. The 20-pixel threshold can be changed with the browser.display.auto_quality_min_font_size preference.
Opera – Full support
Opera 15 (Release date: 2013-07-02)
footnote
footnote Opera treats auto as optimizeSpeed.
Safari – Full support
Safari 5 (Release date: 2010-06-07)
footnote
footnote Safari treats auto as optimizeSpeed. See bug 41363.
Chrome Android – Full support
Chrome Android 18 (Release date: 2012-06-27)
footnote
footnote Chrome Android treats auto as optimizeSpeed.
Firefox for Android – Full support
Firefox for Android 46 (Release date: 2016-04-26)
footnote
footnote If the font size is 20 pixels or higher, Firefox treats auto as optimizeLegibility. For smaller text, Firefox treats auto as optimizeSpeed. The 20-pixel threshold can be changed with the browser.display.auto_quality_min_font_size preference.
Opera Android – Full support
Opera Android 14 (Release date: 2013-05-21)
footnote
footnote Opera Android treats auto as optimizeSpeed.
Safari on iOS – Full support
Safari on iOS 4.2 (Release date: 2010-11-22)
footnote
footnote Safari on iOS treats auto as optimizeSpeed. See bug 41363.
Samsung Internet – Full support
Samsung Internet 1 (Release date: 2013-04-27)
footnote
footnote Samsung Internet treats auto as optimizeSpeed.
WebView Android – Full support
WebView Android 4.4 (Release date: 2013-12-09)
footnote
footnote WebView Android treats auto as optimizeSpeed.
WebView on iOS – Full support
WebView on iOS 4.2 (Release date: 2010-11-22)
footnote
footnote WebView on iOS treats auto as optimizeSpeed. See bug 41363.
geometricPrecision
Chrome – Full support
Chrome 13 (Release date: 2011-08-02)
footnote
footnote Supports true geometric precision without rounding up or down to the nearest supported font size in the operating system.
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote
footnote Supports true geometric precision without rounding up or down to the nearest supported font size in the operating system.
Firefox – Full support
Firefox 1 (Release date: 2004-11-09)
footnote
footnote Firefox treats geometricPrecision the same as optimizeLegibility.
Opera – Full support
Opera 15 (Release date: 2013-07-02)
footnote
footnote Supports true geometric precision without rounding up or down to the nearest supported font size in the operating system.
Safari – Full support
Safari 6 (Release date: 2012-07-25)
footnote Full support
Chrome Android – Full support
Chrome Android 18 (Release date: 2012-06-27)
footnote
footnote Supports true geometric precision without rounding up or down to the nearest supported font size in the operating system.
Firefox for Android – Full support
Firefox for Android 46 (Release date: 2016-04-26)
footnote
footnote Firefox treats geometricPrecision the same as optimizeLegibility.
Opera Android – Full support
Opera Android 14 (Release date: 2013-05-21)
footnote
footnote Supports true geometric precision without rounding up or down to the nearest supported font size in the operating system.
Safari on iOS – Full support
Safari on iOS 6 (Release date: 2012-09-10)
footnote Full support
Samsung Internet – Full support
Samsung Internet 1 (Release date: 2013-04-27)
footnote
footnote Supports true geometric precision without rounding up or down to the nearest supported font size in the operating system.
WebView Android – Full support
WebView Android 4.4 (Release date: 2013-12-09)
footnote
footnote Supports true geometric precision without rounding up or down to the nearest supported font size in the operating system.
WebView on iOS – Full support
WebView on iOS 6 (Release date: 2012-09-10)
footnote Full support
optimizeLegibility
Chrome – Full support
Chrome 31 (Release date: 2013-11-12)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 50 (Release date: 2016-11-15)
footnote Full support
Opera – Full support
Opera 18 (Release date: 2013-11-19)
footnote Full support
Safari – Full support
Safari 5 (Release date: 2010-06-07)
footnote Full support
Chrome Android – Full support
Chrome Android 31 (Release date: 2013-11-14)
footnote Full support
Firefox for Android – Full support
Firefox for Android 50 (Release date: 2016-11-15)
footnote Full support
Opera Android – Full support
Opera Android 18 (Release date: 2013-11-20)
footnote Full support
Safari on iOS – Full support
Safari on iOS 4.2 (Release date: 2010-11-22)
footnote Full support
Samsung Internet – Full support
Samsung Internet 2 (Release date: 2014-10-17)
footnote Full support
WebView Android – Full support
WebView Android 4.4.3 (Release date: 2014-06-02)
footnote Full support
WebView on iOS – Full support
WebView on iOS 4.2 (Release date: 2010-11-22)
footnote Full support
optimizeSpeed
Chrome – Full support
Chrome 31 (Release date: 2013-11-12)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 50 (Release date: 2016-11-15)
footnote Full support
Opera – Full support
Opera 18 (Release date: 2013-11-19)
footnote Full support
Safari – Full support
Safari 5 (Release date: 2010-06-07)
footnote Full support
Chrome Android – Full support
Chrome Android 31 (Release date: 2013-11-14)
footnote Full support
Firefox for Android – Full support
Firefox for Android 50 (Release date: 2016-11-15)
footnote Full support
Opera Android – Full support
Opera Android 18 (Release date: 2013-11-20)
footnote Full support
Safari on iOS – Full support
Safari on iOS 4.2 (Release date: 2010-11-22)
footnote Full support
Samsung Internet – Full support
Samsung Internet 2 (Release date: 2014-10-17)
footnote Full support
WebView Android – Full support
WebView Android 4.4.3 (Release date: 2014-06-02)
footnote Full support
WebView on iOS – Full support
WebView on iOS 4.2 (Release date: 2010-11-22)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
See implementation notes.

See also