CSS text-rendering Property
The CSS text-rendering property provides a rendering hint that allows authors to express a preference for text appearance, rendering speed, or geometric precision.
It can influence how a browser handles typographic features such as kerning and ligatures, but the exact results depend on the browser, font, operating system, and rendering engine.
Unlike properties that directly control text size or spacing, text-rendering is a rendering preference rather than a guarantee of a particular visual result.
text-rendering Syntax
The property accepts one keyword that expresses a preference for how text should be rendered.
Basic Syntax
.example {
text-rendering: optimizeLegibility;
}
Available Values
.example {
text-rendering: auto;
}
.example {
text-rendering: optimizeSpeed;
}
.example {
text-rendering: optimizeLegibility;
}
.example {
text-rendering: geometricPrecision;
}
CSS-Wide Keywords
.example {
text-rendering: initial;
}
.example {
text-rendering: inherit;
}
.example {
text-rendering: unset;
}
.example {
text-rendering: revert;
}
.example {
text-rendering: revert-layer;
}
The initial value is auto. Because the property is inherited, unset behaves like inherit.
Valid Examples
.heading {
text-rendering: optimizeLegibility;
}
.small-label {
text-rendering: optimizeSpeed;
}
.precise-text {
text-rendering: geometricPrecision;
}
Invalid Examples
.example {
text-rendering: smooth;
}
.example {
text-rendering: antialiased;
}
.example {
text-rendering: optimizeQuality;
}
.example {
text-rendering: 100%;
}
.example {
text-rendering: auto optimizeLegibility;
}
The property does not accept percentages, multiple rendering keywords, or arbitrary smoothing values.
Property Values
| Value | Description |
|---|---|
auto |
Allows the rendering engine to balance text quality, speed, and precision according to its own rules. |
optimizeSpeed |
Expresses a preference for rendering speed over typographic quality or geometric precision. |
optimizeLegibility |
Expresses a preference for readability and typographic quality, potentially influencing kerning and ligatures. |
geometricPrecision |
Expresses a preference for precise rendering of glyph outlines and geometric shapes. |
Property Characteristics
| Characteristic | Value |
|---|---|
| Initial value | auto |
| Inherited | Yes |
| Applies to | Text elements |
| Computed value | Specified keyword |
| Animation type | Discrete |
| Percentages | Not applicable |
| Lengths | Not accepted |
| Specification | SVG 1.1 |
Note: The text-rendering property originated in SVG and is also implemented for HTML text by several browsers. Its effects on HTML are not standardized as a general-purpose CSS typography control.
How It Works
Text rendering involves several operations, including selecting glyphs, positioning characters, applying typographic features, and drawing glyph outlines.
The text-rendering property provides a hint about which rendering characteristics should receive priority.
Step 1: Create a Text Element
<h2 class="rendered-heading">Typography Example</h2>
Step 2: Apply a Font
.rendered-heading {
font-family: Georgia, serif;
font-size: 32px;
}
Step 3: Request Legibility Optimization
.rendered-heading {
font-family: Georgia, serif;
font-size: 32px;
text-rendering: optimizeLegibility;
}
The browser may use typographic features that improve the appearance of the text.
Step 4: Compare Rendering Preferences
.rendered-heading {
text-rendering: optimizeSpeed;
}
This requests a preference for rendering speed. Whether any visible change occurs depends on the rendering engine.
Important Consideration
The browser is not required to produce a visible difference between rendering values. Fonts and operating systems may already apply similar rendering behavior by default.
The auto Value
The auto value allows the browser to select its normal text rendering behavior.
Basic Example
.normal-text {
text-rendering: auto;
}
Default Rendering
Because auto is the initial value, it does not need to be explicitly declared for normal rendering.
Browser Decisions
The browser can consider font size, font features, rendering performance, and platform-specific text rendering behavior.
When to Use auto
Use auto for most ordinary website text. It allows the browser to apply its established rendering defaults.
Restoring Automatic Rendering
.special-text {
text-rendering: optimizeLegibility;
}
.normal-text {
text-rendering: auto;
}
The second rule restores automatic rendering for the selected element.
The optimizeSpeed Value
The optimizeSpeed value expresses a preference for faster rendering over typographic refinements.
Basic Example
.fast-text {
text-rendering: optimizeSpeed;
}
Possible Rendering Behavior
A rendering engine may reduce certain typographic processing operations when prioritizing speed. The exact behavior is implementation-dependent.
Small Text Labels
.small-label {
font-size: 12px;
text-rendering: optimizeSpeed;
}
Performance Considerations
Using optimizeSpeed does not guarantee measurable performance improvements. Modern browsers often optimize text rendering automatically.
When to Use optimizeSpeed
It may be useful when working with SVG text or other rendering scenarios where the browser recognizes the hint and performance is a priority.
Important Consideration
Do not use optimizeSpeed as a substitute for actual performance testing or assume that it will improve page loading speed.
The optimizeLegibility Value
The optimizeLegibility value expresses a preference for readable, high-quality text rendering.
Basic Example
.legible-text {
text-rendering: optimizeLegibility;
}
Kerning
Kerning adjusts spacing between specific character pairs, such as AV or To, to improve their visual balance.
.heading {
text-rendering: optimizeLegibility;
}
Ligatures
Ligatures combine certain character sequences into specially designed glyphs when supported by the font.
Examples include fi, fl, and ffi.
Heading Example
.article-heading {
font-family: Georgia, serif;
font-size: 36px;
text-rendering: optimizeLegibility;
}
Browser Differences
Some browsers associate this value with kerning and common ligatures, while others may produce no noticeable change.
When to Use optimizeLegibility
It may be appropriate for prominent headings or typographic demonstrations where the browser supports the rendering hint.
Important Consideration
For predictable control of kerning and ligatures, use the dedicated CSS font properties rather than relying entirely on text-rendering.
The geometricPrecision Value
The geometricPrecision value expresses a preference for accurate rendering of glyph outlines.
Basic Example
.precise-text {
text-rendering: geometricPrecision;
}
SVG Text
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 100">
<text x="20" y="65" text-rendering="geometricPrecision">
SVG Typography
</text>
</svg>
In SVG, this value requests geometric accuracy when rendering text.
CSS Applied to SVG
svg text {
text-rendering: geometricPrecision;
}
Possible Visual Effects
Depending on the rendering engine, this preference may influence how glyph outlines are drawn and positioned.
When to Use geometricPrecision
It is primarily relevant to SVG graphics and other situations where precise glyph geometry is important.
Important Consideration
The value does not guarantee sharper text, better antialiasing, or improved readability in ordinary HTML content.
Kerning and Ligatures
Two typographic features commonly associated with text rendering quality are kerning and ligatures.
Kerning
Kerning adjusts the space between particular character pairs to improve their visual appearance.
.kerned-text {
font-kerning: normal;
}
Disabling Kerning
.un kerned-text {
font-kerning: none;
}
The font-kerning property provides direct control over whether kerning information is used.
Ligatures
Ligatures are glyph substitutions that improve the appearance of certain letter combinations.
.ligature-text {
font-variant-ligatures: common-ligatures;
}
Disabling Common Ligatures
.plain-text {
font-variant-ligatures: no-common-ligatures;
}
Comparing Rendering Hints and Font Properties
| Property | Purpose |
|---|---|
text-rendering |
Provides a general rendering preference. |
font-kerning |
Controls use of kerning information. |
font-variant-ligatures |
Controls ligature substitutions. |
font-feature-settings |
Provides lower-level access to OpenType font features. |
Important Consideration
Font features depend on the selected font. A property cannot enable a feature that the font does not provide.
Related Font Properties
Several CSS properties provide more direct control over typography than text-rendering.
font-kerning
.example {
font-kerning: normal;
}
Controls whether kerning information is applied.
font-variant-ligatures
.example {
font-variant-ligatures: common-ligatures;
}
Controls ligature substitutions supported by the font.
font-feature-settings
.example {
font-feature-settings: "kern" 1, "liga" 1;
}
Provides direct access to specific OpenType features.
font-optical-sizing
.example {
font-optical-sizing: auto;
}
Allows compatible variable fonts to adjust their design according to the displayed text size.
font-smooth
The nonstandard font-smooth property and vendor-specific smoothing properties are sometimes used to influence text antialiasing. They are not reliable cross-browser replacements for standard font controls.
Choosing the Right Property
Use text-rendering for a general rendering preference. Use dedicated font properties when you need explicit control over supported typographic features.
Inheritance
The text-rendering property is inherited. Descendant text elements normally use the value specified by their parent unless they override it.
Inherited Rendering Preference
.article {
text-rendering: optimizeLegibility;
}
Text inside the article inherits the rendering preference.
Overriding the Parent Value
.article {
text-rendering: optimizeLegibility;
}
.article .special-label {
text-rendering: auto;
}
Explicit Inheritance
.child {
text-rendering: inherit;
}
Restoring the Initial Value
.child {
text-rendering: initial;
}
This restores auto.
Using unset
.child {
text-rendering: unset;
}
Because the property is inherited, unset uses the parent's computed value.
Important Consideration
Applying a rendering hint to a parent can affect a large amount of descendant text. Test the result before applying it to an entire website.
Practical Examples
Default Text Rendering
.body-text {
text-rendering: auto;
}
Article Heading
.article-heading {
font-family: Georgia, serif;
font-size: 32px;
text-rendering: optimizeLegibility;
}
Large Display Heading
.display-heading {
font-size: 48px;
font-kerning: normal;
font-variant-ligatures: common-ligatures;
text-rendering: optimizeLegibility;
}
SVG Text
.svg-label {
text-rendering: geometricPrecision;
}
Rendering Speed Preference
.fast-label {
text-rendering: optimizeSpeed;
}
Font Feature Control
.typographic-text {
font-kerning: normal;
font-variant-ligatures: common-ligatures;
}
Disable Ligatures
.code-label {
font-variant-ligatures: none;
}
Optical Sizing
.variable-font-text {
font-optical-sizing: auto;
}
Feature Detection
@supports (text-rendering: optimizeLegibility) {
.heading {
text-rendering: optimizeLegibility;
}
}
Feature detection checks whether the browser recognizes the declaration. It does not guarantee that the rendering hint will visibly change the text.
text-rendering Example
This example compares the four rendering values using identical text. Differences may be subtle or absent depending on the browser, font, and operating system.
HTML Example
<div class="text-rendering-demo">
<div class="rendering-sample">
<strong>auto</strong>
<p class="render-auto">AVATAR Office Typography</p>
</div>
<div class="rendering-sample">
<strong>optimizeSpeed</strong>
<p class="render-speed">AVATAR Office Typography</p>
</div>
<div class="rendering-sample">
<strong>optimizeLegibility</strong>
<p class="render-legibility">AVATAR Office Typography</p>
</div>
<div class="rendering-sample">
<strong>geometricPrecision</strong>
<p class="render-precision">AVATAR Office Typography</p>
</div>
</div>
CSS Example
.text-rendering-demo {
display: grid;
gap: 16px;
}
.text-rendering-demo .rendering-sample {
padding: 16px;
border: 1px solid #cbd5e1;
background: #f8fafc;
}
.text-rendering-demo strong {
display: block;
margin-bottom: 10px;
color: #334155;
font-size: 14px;
}
.text-rendering-demo p {
margin: 0;
color: #1f2937;
font-family: Georgia, serif;
font-size: 28px;
line-height: 1.5;
overflow-wrap: anywhere;
}
.text-rendering-demo .render-auto {
text-rendering: auto;
}
.text-rendering-demo .render-speed {
text-rendering: optimizeSpeed;
}
.text-rendering-demo .render-legibility {
text-rendering: optimizeLegibility;
}
.text-rendering-demo .render-precision {
text-rendering: geometricPrecision;
}
AVATAR Office Typography
AVATAR Office Typography
AVATAR Office Typography
AVATAR Office Typography
Comparing the Results
| Value | Rendering Preference |
|---|---|
auto |
Allows the browser to choose its normal rendering behavior. |
optimizeSpeed |
Requests a preference for rendering performance. |
optimizeLegibility |
Requests a preference for readability and typographic quality. |
geometricPrecision |
Requests a preference for accurate glyph geometry. |
Changing the Font
.text-rendering-demo p {
font-family: "Times New Roman", serif;
}
Different fonts may produce different results because they contain different glyph designs and typographic features.
Increasing the Font Size
.text-rendering-demo p {
font-size: 40px;
}
Larger text may make differences in kerning or glyph appearance easier to observe.
Using Direct Kerning Control
.text-rendering-demo p {
font-kerning: normal;
}
This explicitly requests normal kerning behavior for the text.
Accessibility Considerations
Text rendering quality can affect readability, but rendering hints alone do not guarantee accessible typography.
Use Readable Fonts
Choose fonts with clear character shapes and appropriate spacing.
Maintain Sufficient Font Sizes
Small text can be difficult to read regardless of the selected rendering hint.
Preserve Contrast
Ensure that text has sufficient contrast against its background.
Avoid Relying on Subtle Rendering Differences
Rendering hints may behave differently across devices and should not be required for understanding the content.
Test Text Zoom
Verify that text remains readable when users increase browser zoom or text size.
Respect Font Preferences
Do not rely on a particular font being available on every device.
Use Standard Font Controls
When kerning or ligatures need adjustment, prefer the dedicated font properties.
Avoid Unnecessary Global Overrides
Applying rendering hints to an entire document may create inconsistent results across browsers.
Test Across Platforms
Compare text appearance on different operating systems and browsers, especially when typography is an important part of the design.
Common Mistakes
Expecting Identical Results Across Browsers
The property is a rendering hint, and browsers may interpret or ignore its values differently.
Using optimizeLegibility as a Guaranteed Kerning Control
Use font-kerning when explicit kerning behavior is needed.
Assuming optimizeSpeed Improves Page Loading
The value does not guarantee faster page loading or measurable rendering improvements.
Assuming geometricPrecision Makes Text Sharper
The value expresses a preference for geometric accuracy, not guaranteed sharpness.
Using Unsupported Values
.example {
text-rendering: antialiased;
}
The antialiased keyword is not a valid value for this property.
Using Multiple Keywords
.example {
text-rendering: optimizeSpeed optimizeLegibility;
}
Only one rendering keyword can be specified.
Confusing text-rendering With font-smooth
The properties have different purposes, and font smoothing controls are not consistently standardized across browsers.
Ignoring Font Support
Kerning and ligatures depend on the font's available typographic features.
Applying Rendering Hints Globally Without Testing
Because the property is inherited, a declaration on a parent can affect many descendant elements.
Using text-rendering Instead of Proper Typography
Readable typography also depends on font choice, size, spacing, line height, and contrast.
Expecting Visible Changes in Every Example
Modern browsers may already apply similar rendering behavior with the default auto value.
Important Considerations
Keep the following points in mind when using text-rendering:
- The property provides a rendering preference rather than a guaranteed visual result.
- It originated in SVG and is also implemented for HTML text by several browsers.
- Its behavior on HTML text is not standardized as a general CSS typography control.
- The initial value is
auto. - The property is inherited.
- The recognized values are
auto,optimizeSpeed,optimizeLegibility, andgeometricPrecision. - The
autovalue allows the browser to select its normal rendering behavior. - The
optimizeSpeedvalue expresses a preference for rendering performance. - The
optimizeLegibilityvalue expresses a preference for readability and typographic quality. - The
geometricPrecisionvalue expresses a preference for accurate glyph geometry. - Only one rendering keyword can be specified.
- Lengths and percentages are not accepted.
- Browser implementations may ignore some rendering hints.
- Visible differences may depend on the font and operating system.
- Kerning adjusts spacing between selected character pairs.
- Ligatures replace certain character sequences with specially designed glyphs.
- Font features must be supported by the selected font.
- The
font-kerningproperty provides direct kerning control. - The
font-variant-ligaturesproperty provides direct ligature control. - The
font-feature-settingsproperty provides lower-level OpenType controls. - Rendering hints do not guarantee performance improvements.
- Rendering hints do not replace appropriate font sizes, spacing, or contrast.
- Applying the property to a parent affects descendant text through inheritance.
- Test typography across browsers, operating systems, and font families.
Browser Support
The text-rendering property has limited availability as a CSS property for HTML text. Support and rendering behavior vary among browsers, and some values may be recognized without producing a noticeable visual effect.
The property is defined for SVG text, where rendering hints are part of the SVG specification. Support for its use with ordinary HTML text is less consistent.
For current compatibility information, visit Can I Use? and search for text-rendering.
Basic Example
.heading {
text-rendering: optimizeLegibility;
}
Feature Detection
@supports (text-rendering: optimizeLegibility) {
.heading {
text-rendering: optimizeLegibility;
}
}
This checks whether the browser recognizes the declaration. It does not confirm that kerning, ligatures, or other rendering behavior will change.
More Predictable Typography
.heading {
font-kerning: normal;
font-variant-ligatures: common-ligatures;
}
These properties offer more explicit control over supported font features.
Testing Recommendations
Compare the same font and text across browsers and operating systems. Include character pairs such as AV and sequences such as fi when checking typographic differences.
Specifications
The text-rendering property is defined in the SVG 1.1 specification as a rendering hint for text.
SVG 1.1 - text-rendering Property
The SVG specification describes how rendering engines may prioritize speed, legibility, and geometric precision.
For additional documentation and browser-specific information, consult MDN Web Docs.
