CSS text-size-adjust Property
The CSS text-size-adjust property controls whether a browser can automatically adjust text sizes to improve readability on mobile devices.
Some mobile browsers enlarge text when displaying content designed for wider screens. The text-size-adjust property lets authors permit, disable, or influence this automatic text inflation. It does not replace font-size or control ordinary browser zoom.
text-size-adjust Syntax
The property accepts the keywords auto and none, or a nonnegative percentage.
Basic Syntax
html {
text-size-adjust: auto;
}
Available Values
html {
text-size-adjust: auto;
}
html {
text-size-adjust: none;
}
html {
text-size-adjust: 100%;
}
html {
text-size-adjust: 120%;
}
CSS-Wide Keywords
html {
text-size-adjust: initial;
}
html {
text-size-adjust: inherit;
}
html {
text-size-adjust: unset;
}
html {
text-size-adjust: revert;
}
html {
text-size-adjust: revert-layer;
}
The initial value is auto. The property is inherited, so unset behaves like inherit.
Valid Examples
html {
text-size-adjust: auto;
}
body {
text-size-adjust: 100%;
}
.article {
text-size-adjust: 125%;
}
.example {
text-size-adjust: 0%;
}
A percentage of 0% is syntactically valid, although disabling automatic text inflation can create readability problems.
Invalid Examples
html {
text-size-adjust: 16px;
}
html {
text-size-adjust: 1.2em;
}
html {
text-size-adjust: -20%;
}
html {
text-size-adjust: normal;
}
html {
text-size-adjust: auto 100%;
}
The property does not accept lengths, negative percentages, the keyword normal, or multiple values.
Property Values
| Value | Description |
|---|---|
auto |
Allows the browser to apply its normal automatic text-sizing behavior. |
none |
Disables automatic text inflation controlled by this property. |
<percentage> |
Specifies a preferred text inflation percentage where supported. Browser behavior and support vary. |
initial |
Restores the initial value, auto. |
inherit |
Uses the computed value of the parent element. |
unset |
Inherits the value because the property is inherited. |
revert |
Reverts the property according to the CSS cascade origin. |
revert-layer |
Reverts the property according to the previous cascade layer. |
Property Characteristics
| Characteristic | Value |
|---|---|
| Initial value | auto |
| Inherited | Yes |
| Applies to | Elements |
| Computed value | Specified keyword or percentage |
| Animation type | Discrete |
| Percentages | Nonnegative values |
| Lengths | Not accepted |
| Specification | CSS Mobile Text Size Adjustment Module Level 1 |
Note: Browser support for percentage values is less consistent than support for the auto and none keywords. A percentage should not be treated as a reliable replacement for font-size.
How It Works
Mobile text inflation is a browser feature that can enlarge text when a page is displayed at a scale that would otherwise make the text difficult to read.
Step 1: Define the Text Size
.article {
font-size: 16px;
}
This establishes the CSS font size before any automatic browser adjustment.
Step 2: Allow Automatic Adjustment
.article {
font-size: 16px;
text-size-adjust: auto;
}
A supporting mobile browser can adjust the displayed text when its text inflation algorithm determines that adjustment is needed.
Step 3: Disable Automatic Adjustment
.article {
font-size: 16px;
text-size-adjust: none;
}
This requests that the browser not apply automatic text inflation to the selected content.
Step 4: Specify a Percentage
.article {
font-size: 16px;
text-size-adjust: 120%;
}
Where supported, this requests a text inflation percentage of 120%. It does not mean that the browser must render the text at exactly 19.2 pixels in every situation.
Important Consideration
The property has no visible effect when the browser is not performing automatic text inflation. On desktop browsers, changing its value commonly produces no noticeable result.
The auto Value
The auto value allows the browser to decide whether automatic text inflation is necessary.
Basic Example
html {
text-size-adjust: auto;
}
Default Behavior
Because auto is the initial value, an explicit declaration is normally unnecessary.
Mobile Readability
On pages designed for wider viewports, mobile browsers may enlarge certain text to make it more readable.
Responsive Layouts
html {
text-size-adjust: auto;
}
body {
font-size: 1rem;
line-height: 1.5;
}
This allows the browser to retain control of automatic text inflation while the page uses standard responsive typography.
When to Use auto
Use auto for most websites, particularly when preserving browser readability features is important.
The none Value
The none value disables automatic text inflation controlled by this property.
Basic Example
html {
text-size-adjust: none;
}
What It Changes
On supporting mobile browsers, the browser will not automatically enlarge text through its text inflation algorithm.
What It Does Not Change
The declaration does not directly change the specified font-size or necessarily prevent users from zooming or adjusting text through browser accessibility settings.
Element-Specific Example
.fixed-label {
text-size-adjust: none;
}
Where the browser supports element-level behavior, this requests that automatic text inflation be disabled for the selected content.
Accessibility Warning
Disabling automatic text inflation can make text too small to read on narrow screens, especially on pages that are not fully responsive.
When to Use none
Use this value only when there is a specific reason to suppress text inflation and the resulting text remains readable on the intended devices.
Percentage Values
Percentage values express a preferred amount of automatic text inflation. Their effects are browser-dependent.
100% Example
html {
text-size-adjust: 100%;
}
Where implemented, 100% represents a 100% text inflation scale. It is often used in mobile browser stylesheets to prevent unexpected enlargement, but it is not equivalent to auto.
120% Example
html {
text-size-adjust: 120%;
}
This requests a larger text inflation scale in implementations that support percentage values.
150% Example
html {
text-size-adjust: 150%;
}
Percentage Comparison
| Value | Requested Behavior |
|---|---|
0% |
Zero percent text inflation, where supported. |
100% |
Text inflation scale of 100%. |
120% |
Text inflation scale of 120%. |
150% |
Text inflation scale of 150%. |
Percentage Values vs. font-size
.example {
font-size: 120%;
}
The font-size property directly changes the element's font size relative to its inherited font size.
.example {
text-size-adjust: 120%;
}
The text-size-adjust property instead influences a browser's automatic text inflation behavior.
Important Consideration
Do not rely on percentage values to produce a consistent font size across devices. Use font-size for predictable typography.
Mobile Text Inflation
Mobile text inflation is intended to improve readability when a webpage is displayed on a small screen.
Why Text Inflation Exists
Older websites often used fixed-width layouts designed for desktop monitors. When displayed on mobile screens, the browser could shrink the page to fit, making text difficult to read.
Automatic Enlargement
Some mobile browsers enlarge text in selected areas while attempting to preserve the overall layout.
Browser-Specific Algorithms
The decision to enlarge text can depend on viewport settings, layout width, text blocks, and browser-specific rules.
Responsive Layouts
.content {
width: 100%;
max-width: 900px;
margin-inline: auto;
padding: 20px;
}
A responsive layout reduces the need for automatic text inflation by allowing content to fit the available screen width.
Readable Typography
body {
font-size: 1rem;
line-height: 1.6;
}
Readable font sizes and appropriate line spacing are more reliable than depending on automatic browser enlargement.
Important Consideration
Automatic text inflation is not the same as browser zoom. The two features may operate independently.
Viewport Meta Tag
The viewport meta tag influences how mobile browsers size and scale webpages.
Recommended Viewport Declaration
<meta name="viewport" content="width=device-width, initial-scale=1.0">
This instructs the browser to use the device width as the layout viewport and establishes an initial scale of 1.
Combining Viewport Settings With CSS
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Responsive Text Example</title>
<style>
html {
text-size-adjust: auto;
}
body {
font-size: 1rem;
line-height: 1.6;
}
</style>
</head>
<body>
<p>This paragraph uses responsive text settings.</p>
</body>
</html>
Why the Viewport Matters
A properly configured viewport helps responsive CSS behave as intended and reduces situations where a mobile browser needs to compensate for a desktop-sized layout.
Avoid Restricting User Zoom
Do not disable zoom using restrictive viewport settings such as user-scalable=no. Users may need to enlarge text to read it comfortably.
Important Consideration
The viewport meta tag and text-size-adjust serve different purposes. The viewport controls page scaling and layout dimensions, while text-size-adjust influences automatic text inflation.
Vendor Prefixes
Some browsers historically implemented text size adjustment using vendor-prefixed properties.
WebKit Prefix
html {
-webkit-text-size-adjust: 100%;
}
The -webkit-text-size-adjust property is used by WebKit-based browsers and some other browser implementations.
Microsoft Prefix
html {
-ms-text-size-adjust: 100%;
}
The -ms-text-size-adjust property was used by older Microsoft browser implementations.
Combined Declarations
html {
-webkit-text-size-adjust: 100%;
text-size-adjust: 100%;
}
When compatibility with implementations that require the WebKit prefix is necessary, place the prefixed declaration before the standard declaration.
Legacy Compatibility
html {
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
text-size-adjust: 100%;
}
The Microsoft-prefixed declaration is primarily relevant to legacy browser support.
Important Consideration
Vendor prefixes do not guarantee identical behavior across browsers. Test the property on actual mobile devices when its behavior matters.
Inheritance
The text-size-adjust property is inherited, allowing a value declared on a parent to apply to descendant elements.
Root Element Example
html {
text-size-adjust: auto;
}
Descendant elements inherit the value unless another declaration overrides it.
Parent and Child Example
.article {
text-size-adjust: auto;
}
.article .special-text {
text-size-adjust: none;
}
The child requests different behavior from its parent, although actual element-level effects depend on browser support.
Explicit Inheritance
.child {
text-size-adjust: inherit;
}
Restoring the Initial Value
.child {
text-size-adjust: initial;
}
This restores auto.
Using unset
.child {
text-size-adjust: unset;
}
Because the property is inherited, unset uses the parent's computed value.
Important Consideration
Applying text-size-adjust: none to the root element can suppress text inflation throughout the page on supporting browsers. Consider the accessibility consequences before using a global override.
Related CSS Properties
Several CSS properties and techniques provide more predictable control over text sizing and responsive typography.
font-size
.example {
font-size: 1rem;
}
Directly specifies the font size.
line-height
.example {
line-height: 1.6;
}
Controls spacing between lines of text.
Responsive Font Size With clamp()
.heading {
font-size: clamp(1.5rem, 4vw, 3rem);
}
Allows the font size to respond to viewport width within specified limits.
Media Queries
.heading {
font-size: 2rem;
}
@media (max-width: 600px) {
.heading {
font-size: 1.5rem;
}
}
Changes the font size at a selected viewport width.
Comparison
| Feature | Purpose |
|---|---|
text-size-adjust |
Influences automatic browser text inflation. |
font-size |
Sets the actual CSS font size. |
line-height |
Controls line spacing. |
clamp() |
Creates a fluid value within minimum and maximum limits. |
| Media queries | Apply styles according to viewport or device conditions. |
Practical Examples
Allow Automatic Text Inflation
html {
text-size-adjust: auto;
}
WebKit Compatibility
html {
-webkit-text-size-adjust: auto;
text-size-adjust: auto;
}
Specify 100% Text Inflation
html {
-webkit-text-size-adjust: 100%;
text-size-adjust: 100%;
}
Disable Automatic Text Inflation
.fixed-content {
text-size-adjust: none;
}
Use this cautiously because it may reduce readability on mobile devices.
Request Larger Text Inflation
.article {
text-size-adjust: 125%;
}
Percentage behavior is not consistent across browsers.
Responsive Body Text
html {
text-size-adjust: auto;
}
body {
font-size: 1rem;
line-height: 1.6;
}
Fluid Heading
.page-heading {
font-size: clamp(1.5rem, 3vw, 2.5rem);
line-height: 1.2;
}
Responsive Content Width
.content {
width: min(100%, 70rem);
margin-inline: auto;
padding-inline: 1rem;
}
Small-Screen Typography
.article {
font-size: 1rem;
}
@media (max-width: 600px) {
.article {
font-size: 1.0625rem;
}
}
This directly increases the CSS font size on narrow screens without relying on text inflation.
Restore Browser Defaults
.content {
text-size-adjust: auto;
}
text-size-adjust Example
This example shows the syntax for several text-size-adjust values. The rendered text may look identical because the property only affects automatic text inflation in browsers and situations where that feature is active.
HTML Example
<div class="text-size-adjust-demo">
<div class="size-sample">
<strong>auto</strong>
<p class="size-auto">Automatic text adjustment is allowed.</p>
</div>
<div class="size-sample">
<strong>none</strong>
<p class="size-none">Automatic text adjustment is disabled.</p>
</div>
<div class="size-sample">
<strong>100%</strong>
<p class="size-100">A 100% text inflation scale is requested.</p>
</div>
<div class="size-sample">
<strong>120%</strong>
<p class="size-120">A 120% text inflation scale is requested.</p>
</div>
</div>
CSS Example
.text-size-adjust-demo {
display: grid;
gap: 16px;
}
.text-size-adjust-demo .size-sample {
padding: 16px;
border: 1px solid #cbd5e1;
background: #f8fafc;
}
.text-size-adjust-demo strong {
display: block;
margin-bottom: 8px;
color: #334155;
font-size: 14px;
}
.text-size-adjust-demo p {
margin: 0;
color: #1f2937;
font-size: 16px;
line-height: 1.6;
}
.text-size-adjust-demo .size-auto {
-webkit-text-size-adjust: auto;
text-size-adjust: auto;
}
.text-size-adjust-demo .size-none {
-webkit-text-size-adjust: none;
text-size-adjust: none;
}
.text-size-adjust-demo .size-100 {
-webkit-text-size-adjust: 100%;
text-size-adjust: 100%;
}
.text-size-adjust-demo .size-120 {
-webkit-text-size-adjust: 120%;
text-size-adjust: 120%;
}
Automatic text adjustment is allowed.
Automatic text adjustment is disabled.
A 100% text inflation scale is requested.
A 120% text inflation scale is requested.
Understanding the Results
All four samples use the same declared font-size. If the browser is not applying automatic text inflation, the samples should appear the same size.
Testing on Mobile Devices
To investigate the differences, test the declarations in a mobile browser where automatic text inflation is active. The behavior may vary with the viewport configuration and page layout.
Changing the Actual Font Size
.text-size-adjust-demo .size-120 {
font-size: 20px;
}
Unlike text-size-adjust: 120%, this declaration directly sets the CSS font size to 20 pixels.
Accessibility Considerations
Automatic text inflation is a browser feature intended to improve readability, especially on small screens.
Preserve Browser Readability Features
Prefer auto unless there is a clear reason to change the browser's automatic text-sizing behavior.
Avoid Global Disabling
Using text-size-adjust: none on the root element may make text harder to read on mobile devices.
Use Readable Font Sizes
Choose font sizes that remain comfortable to read without requiring browser-specific adjustments.
Allow Text Enlargement
Users should be able to enlarge text using browser zoom, text scaling, or accessibility settings.
Use Responsive Layouts
Responsive layouts help prevent text from becoming excessively small when a page is displayed on a narrow screen.
Avoid Fixed-Width Text Containers
Wide fixed-width layouts can force mobile browsers to shrink the page, making text more difficult to read.
Test With Larger Text
Check that content remains readable and usable when text is enlarged substantially.
Maintain Appropriate Line Spacing
Use sufficient line-height to prevent enlarged text from appearing crowded.
Do Not Disable Zoom
Avoid viewport settings that unnecessarily restrict the user's ability to zoom.
Test on Actual Devices
Mobile browsers may handle automatic text inflation differently, so testing on real devices is valuable.
Common Mistakes
Confusing text-size-adjust With font-size
The font-size property directly controls text size. The text-size-adjust property influences automatic browser text inflation.
Expecting a Visible Desktop Effect
Desktop browsers generally do not apply mobile text inflation, so changing this property may have no visible effect.
Assuming 120% Always Enlarges Text
Percentage values are not consistently implemented and may have no effect in some browsers.
Disabling Text Inflation Globally
html {
text-size-adjust: none;
}
This can reduce mobile readability when the browser would otherwise enlarge small text.
Using Length Values
html {
text-size-adjust: 18px;
}
Lengths are not valid values for this property.
Using Negative Percentages
html {
text-size-adjust: -25%;
}
Negative percentages are invalid.
Using the normal Keyword
html {
text-size-adjust: normal;
}
The correct keyword for automatic browser behavior is auto.
Assuming Vendor Prefixes Behave Identically
Prefixed and unprefixed implementations may have different support or behavior.
Ignoring the Viewport Meta Tag
Incorrect viewport settings can affect how mobile browsers scale a page and whether text inflation is needed.
Using Text Inflation Instead of Responsive Design
A responsive layout with readable font sizes is more reliable than depending on automatic browser adjustments.
Assuming none Disables All Text Enlargement
The property controls automatic text inflation, not every form of user-controlled text scaling or browser zoom.
Relying Only on Browser Emulation
Desktop device emulation may not reproduce the text inflation behavior of an actual mobile browser.
Important Considerations
Keep the following points in mind when using text-size-adjust:
- The property influences automatic browser text inflation.
- It is primarily relevant to mobile browsers.
- The initial value is
auto. - The property is inherited.
- The
autovalue allows normal browser text inflation behavior. - The
nonevalue disables automatic text inflation controlled by the property. - Nonnegative percentage values are syntactically valid.
- Percentage support and behavior vary among browsers.
- The property does not directly replace
font-size. - The property does not control ordinary browser zoom.
- Desktop browsers may show no visible effect.
- Mobile text inflation algorithms are browser-dependent.
- Text inflation may depend on viewport configuration and layout width.
- Responsive layouts reduce the need for automatic text inflation.
- The viewport meta tag helps establish appropriate mobile layout dimensions.
- Vendor-prefixed declarations may be necessary for selected browser implementations.
- The
-webkit-text-size-adjustproperty is commonly used for WebKit compatibility. - The
-ms-text-size-adjustproperty is primarily relevant to legacy Microsoft browsers. - Disabling automatic text inflation can reduce readability.
- Use appropriate font sizes and line spacing for mobile content.
- Do not restrict user zoom unnecessarily.
- Test on actual mobile devices when the property is important to the design.
Browser Support
The CSS text-size-adjust property has limited availability across browsers. Support varies between mobile and desktop implementations, and some browsers require the -webkit- prefix.
Even when a browser recognizes the declaration, it may not visibly change text unless automatic text inflation is active.
For current compatibility information, visit Can I Use? and search for text-size-adjust.
Standard Declaration
html {
text-size-adjust: auto;
}
WebKit Compatibility
html {
-webkit-text-size-adjust: auto;
text-size-adjust: auto;
}
Legacy Microsoft Compatibility
html {
-ms-text-size-adjust: auto;
text-size-adjust: auto;
}
Feature Detection
@supports (text-size-adjust: auto) {
html {
text-size-adjust: auto;
}
}
This checks whether the browser recognizes the unprefixed declaration. It does not guarantee that automatic text inflation is active.
Prefixed Feature Detection
@supports (-webkit-text-size-adjust: auto) {
html {
-webkit-text-size-adjust: auto;
}
}
Testing Recommendations
Test the property on mobile browsers with different viewport settings and layout widths. Do not assume that desktop browser emulation reproduces actual mobile text inflation behavior.
Specifications
The text-size-adjust property is defined in the CSS Mobile Text Size Adjustment Module Level 1 specification.
CSS Mobile Text Size Adjustment Module Level 1 - Text Size Adjustment Control
The specification describes how authors can influence automatic text inflation performed by supporting browsers.
For additional documentation and browser-specific behavior, consult MDN Web Docs.
