This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for usage in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the specification changes.
On mobile devices, the text-size-adjust
property allows Web authors to control if and how the text-inflating algorithm is applied to the textual content of the element it is applied to.
As this property is non-standard, it must be used prefixed: -moz-text-size-adjust
, -webkit-text-size-adjust
, and -ms-text-size-adjust
.
Browsers on smartphones don't display web pages using the same algorithms as browsers rendering web pages on desktop machines. Instead of laying out the web page at the width of the device screen, they lay it out using a viewport that is much wider than the device screen, usually of 800 or 1000 pixels wide. One of two possible methods is used to map back to the original device coordinates: either a smaller window is then used to display on the device screen only part of what is actually being rendered, or the viewport is stretched to the size of the device.
In essence, this means that either only a small, rectangular portion of the original web page is usually visible on a mobile device screen or that on mobile devices, the web page looks "zoomed out" and smaller than intended.
This approach has been used as numerous web sites are not able to cope with small screens and are not usable when using the classical layout algorithm. This technique has drawbacks: the text is so tiny that it is unreadable without zooming. Even so, the user experience is better with the classical approach, which often leads to put secondary content at the top of the smartphone display, effectively pushing the main content of the page outside the viewport.
But when the user zoomed in until the text becomes readable, an horizontal scrollbar is often needed as the line becomes larger than the width of the screen. This horizontal scrollbar has to be used to read each line of the text, which is a user experience nightmare. To prevent this, several mobile browsers implement a text inflation algorithm. When a focused element containing text use 100 % of the width of the screen, its text size is increased until it reached a readable size, without modifying the layout and removing the need of an horizontal scrollbar.
The text-size-adjust
property allows Web authors to opt out from this behavior, as Web pages designed to handle small screen widths do not need it.
- This property is not standard. In order to use it, Web authors have to duplicate, or even triplicate it, prefixed for each engine supporting it.
- Its behavior, and even the syntax, is slightly different from one browser engine to the other. Web developers should read the browser compatibility section with the required attention.
- This property only has an effect on smartphones. As there is no inflation algorithm on desktop browsers, and on some tablet browsers like the iPad, the property is not supported there (and ignored). This property is only designed to opt out, or to cancel this opt-out, of the inflating behavior, not to opt in.
- If
-webkit-text-size-adjust
is explicitly set tonone
, old versions of Webkit-based desktop and tablet browsers, like Chrome≤26 or Safari≤5, instead of ignoring the property, will prevent the user to zoom in or out the Web page.# - Not all engines do allow to control the final size of the text using a percentage value (E.g. Webkit and Trident do allow it, Gecko doesn't). Again Web developers should read the browser compatibility section with the required attention.
Initial value | auto for smartphone browsers supporting inflation, none in other cases (and then not modifiable). |
---|---|
Applies to | all elements |
Inherited | yes |
Percentages | yes, refer to the corresponding size of the text font |
Media | visual |
Computed value | as specified |
Animatable | no |
Canonical order | the unique non-ambiguous order defined by the formal grammar |
Syntax
/* Text is never inflated */ text-size-adjust: none; /* Text may be inflated */ text-size-adjust: auto; /* Text may be inflated in this exact proportion */ text-size-adjust: 80%; /* Global values */ text-size-adjust: inherit; text-size-adjust: initial; text-size-adjust: unset;
Values
none
- Is a keyword preventing the usage of the inflation algorithm on the element. Basically, this means that the element will be displayed without its font inflated. On old WebKit-based desktop browsers (Chrome≤26, Safari≤5), this will instead prevent the user from zooming the webpage in or out.
auto
- Is a keyword allowing the usage of the inflation algorithm on the element. Browsers are not forced to use it and they won't do it on desktops and on some tablets. Its main use is to cancel a
none
value previously set. <percentage>
- A percentage value is a synonym of the
auto
keyword, with the additional information that the percentage value is the increase rate to be applied to the font size when the inflation algorithm is applied.
Formal syntax
none | auto | <percentage>
Specifications
Specification | Status | Comment |
---|---|---|
CSS Mobile Text Size Adjustment Module Level 1 The definition of 'text-size-adjust' in that specification. |
Editor's Draft | Initial definition |
Browser compatibility
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | No support[1] | No support | No support | No support | No support[1] |
Percentages | No support | No support | No support | No support | No support |
Feature | Android | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Basic support | ? | 11.0 (11.0) -moz | (Yes) -ms[2] 11-webkit |
No support | (Yes)-webkit |
Percentages | ? | No support | (Yes)[2] | No support | (Yes) |
[1] There is a bug in old Webkit-based desktop browsers. If -webkit-text-size-adjust
is explicitly set to none
, Webkit-based desktop browsers, like Chrome or Safari, instead of ignoring the property, will prevent the user to zoom in or out the Web page. See Bug 56543 (affected Safari≤5 & Chrome≤26), Bug 163359, and Bug 84186.
[2] If the viewport is set using <meta>
element, the value of the CSS text-size-adjust
property is ignored. See detailed implementation hints on MSDN.
See also
- Apple's documentation.
- Gecko's behavior description by L. David Baron.
- Microsoft's documentation.