logoalt Hacker News

pupppetyesterday at 9:41 PM2 repliesview on HN

Why is this set as a meta tag rather than via CSS with html{text-scale:scale} for example?


Replies

ameliaquiningyesterday at 9:57 PM

The linked explainer [1] gets into this:

"The new CSS env(preferred-text-scale) variable provides a mechanism for authors to respect the user’s text scale setting that they’ve set either in their operating system or web browser settings. Authors can use it to scale the font-size and alter the layout accordingly.

Note: See the env(preferred-text-scale) Explainer [2] for a comparison of the various ways users can scale content and examples of how to use the environment variable.

However, if authors have already used font-relative units like rem and em to conform to the Resize Text guideline, the browser could automatically incorporate the OS-level text scale setting into those font-relative units. This would allow authors to avoid having to determine the precise elements to apply the env() variable to.

We propose a new HTML meta tag that tells the user agent to apply the scaling factor from env(preferred-text-scale) to the entire page. We expect it will become best practice for authors to use this meta tag, just as they would use the viewport meta tag. The environment variable would be reserved for atypical use cases."

There's no need for a text-scale CSS property because font-size already exists. The latter explainer [2] suggests that developers use font-size: calc(100% * env(preferred-text-scale)) to get the desired effect, if they are doing this in CSS rather than with just the meta tag.

[1] https://github.com/w3c/csswg-drafts/blob/main/css-env-1/expl... [2] https://github.com/w3c/csswg-drafts/blob/main/css-env-1/expl...

show 1 reply
linolevanyesterday at 9:53 PM

Speculation on my part: Your site either supports accessible text scaling, or it doesn't. If only partly supports it – it might as well not at all.