Definition and Usage
The text-size-adjust property controls automatic text size adjustment on mobile devices.
This property is primarily used in mobile browsers. It may be ignored by desktop browsers.
This property is still experimental. Check Browser Compatibility carefully before using it in production.
Basic Example
html {
-moz-text-size-adjust: none; /* Firefox on Android */
-webkit-text-size-adjust: none; /* Safari on iOS */
text-size-adjust: none;
}
The CSS example shows how to disable automatic text size adjustment across the entire page by applying text-size-adjust: none to the html element.
Because text-size-adjust is an inherited property, applying this example disables automatic text size adjustment for all elements.
Usage Notes
There is some background knowledge you need to understand the text-size-adjust property.
Automatic Text Size Adjustment on Mobile
On mobile devices, which have smaller screens than desktop devices, small text can be automatically enlarged to make it easier for users to read.
Text Inflation Algorithm
Some mobile browsers use a "text inflation algorithm" to make text on web pages easier to read. This algorithm adjusts and enlarges text so that it does not appear too small on small screens. The implementation of the text inflation algorithm may vary across different mobile browsers.
Problems with Original Web Page Designs
Because many websites were not originally designed with mobile devices in mind, mobile browsers render web pages differently from desktop browsers. Mobile browsers use a viewport that is much wider than the screen (typically between 800 and 1,000 pixels) to render pages. To fit this layout to the mobile screen, the browser either scales down the viewport or displays only part of the page.
A viewport is a web browser term that refers to the visible area of a web page displayed in the current window (or the screen when viewing the document in full-screen mode).
Since text that has been scaled down to fit a mobile screen can be very small, many mobile browsers apply a text inflation algorithm to enlarge the text and make it easier to read. When an element containing text uses 100% of the screen width, the algorithm increases the text size without modifying the layout.
Text Inflation Is Primarily a User Readability Feature
Although text inflation is also used to address problems with original web page designs, it is now primarily a feature that improves readability by automatically enlarging text when it appears too small on mobile screens.
The text-size-adjust property allows web authors to disable or modify this feature.
Safari on iOS
This content is excerpted from Apple's Safari Web Content Guide, which describes features related to text size adjustment in the Safari browser. This document primarily explains how Safari on iOS handles text on web pages.
Safari on iOS automatically adjusts text size to make text on web pages easier for users to read. In particular, when a user double-taps an HTML block element (such as a <div> element), Safari zooms in on the viewport to fit the width of that element and adjusts the text size to improve readability.
When a page is first rendered, Safari detects the width of block elements and adjusts the text to an appropriate size to ensure readability. This automatic text size adjustment feature helps web pages display properly on mobile devices.
Safari's automatic text size adjustment can cause unexpected layout issues on web pages. For example, text inside absolutely positioned elements may overflow the viewport. In such cases, you can use the CSS -webkit-text-size-adjust property to disable automatic adjustment or scale the text size to a desired percentage.
For example, setting the property to none disables automatic text size adjustment, while setting it to 200% doubles the text size.
In Safari on iPad, the -webkit-text-size-adjust property is set to none by default, so automatic text size adjustment does not occur. However, on other iOS devices, it defaults to auto, causing text size to adjust automatically.
Setting the text-size-adjust Property
This section explains how to set the text-size-adjust property.
Formal Syntax
selector {
text-size-adjust: auto || none || <percentage>
}
Syntax
/* Keyword values */
text-size-adjust: none; /* Equivalent to text-size-adjust: 100%; */
text-size-adjust: auto;
/* <percentage> value */
text-size-adjust: 100%; /* Equivalent to text-size-adjust: none; */
/* Global values */
text-size-adjust: inherit;
text-size-adjust: initial;
text-size-adjust: revert;
text-size-adjust: revert-layer;
text-size-adjust: unset;
Values
auto |
Enables the browser's text inflation algorithm. |
|---|---|
none |
Disables the browser's text inflation algorithm. |
<percentage> |
Enables the browser's text inflation algorithm and specifies a percentage by which to increase the font size. Negative values are invalid. |
Note!
This means that text-size-adjust: 100% is equivalent to text-size-adjust: none.
Formal Definition
| Initial value | Set to auto in smartphone browsers supporting text inflation, and to none in all other cases (including Safari on iPad). |
|---|---|
| Applies to | all elements |
| Inherited | yes |
Browser Compatibility
Last updated:
| Mobile | |||
|---|---|---|---|
| Property and Value |
Mobile Chrome
|
Mobile Firefox
|
Safari
|
text-size-adjust
|
54 | 49 -moz- | 1 -webkit- |
auto
|
54 | No | No |
none
|
54 | No | No |
<percentage>
|
54 | No | No |
Specifications
| Specification | |
|---|---|
text-size-adjust
|
CSS Mobile Text Size Adjustment Module Level 1 #adjustment-control |