Skip Navigation
amb

An Accessibility Bookmarklet for Testing 200% Text Size

TL;DR

This bookmarklet can help you visually check how well a webpage handles text being resized to 200% of the base/default size. It can also help you test for loss of content when checking compliance for WCAG 2.2 Success Criterion 1.4.10 Reflow.

To add the bookmarklet to your preferred browser:

  1. Create a new bookmark
  2. Give it a good name (maybe "Toggle text zoom")
  3. Copy-and-paste the following code for the URL
1javascript: (function () {
2  const htmlElement = document.querySelector('html');
3  const currentFontSize = htmlElement.style.getPropertyValue('font-size');
4  const isZoomed = currentFontSize === '200%';
5  const newFontSize = isZoomed ? null : '200%';
6  htmlElement.style.setProperty('font-size', newFontSize);
7})();
8

Disclaimer: This is experimental and should be used at your own risk! If a webpage is already coded to set the CSS font-size property on the <html> element, this bookmarklet probably won't work as intended.

Does WCAG have text size requirements?

The Web Content Accessibility Guidelines has one Success Criterion criterion in particular that talks about text size. WCAG 2.2 Success Criterion 1.4.4 Resize Text says:

Except for captions and images of text, text can be resized without assistive technology up to 200 percent without loss of content or functionality.

Text resizing is not the same as browser zoom

You might be thinking, "But when I zoom in my browser to 200% the button text looks fine!" This is probably a common misconception with this Success Criterion. I definitely didn't know for a while that browser zoom is only part of the story!

Digging deeper using the Understanding SC 1.4.4: Resize Text docs, it says we (the "authors") have to handle the case when a user only increases the size of their text since their browser (or some other "user agent") might not have zoom capability.

The docs say:

If the user agent doesn't provide zoom functionality but does let the user change the text size, the author is responsible for ensuring that the content remains usable when the text is resized.

This Success Criterion is one reason why it's good practice to use rem units for the CSS font-size property and no units for the line-height property. Text must be resizeable up to 200% without a mechanism like browser zoom.

How do I test 200% text size?

The easiest way I've found to test text-only zoom is by setting font-size: 200% on the <html> element for a web page. This can be done a few ways:

  1. Manually adding the CSS property in browser dev tools
  2. Running some JavaScript in the browser console
  3. Putting the JavaScript in a bookmarklet and running it with one click

I prefer option 3 the most because it's just one click and it's a more accurate user experience test since I can keep the browser dev tools panel closed.

My bookmarklet is set up to toggle the font-size: 200% setting on the <html> element when the bookmark is clicked. It checks if the current font-size value is already set to 200%, and adds or removes it based on that check.

To add the bookmarklet to your preferred browser:

  1. Create a new bookmark
  2. Give it a good name (maybe "Toggle text zoom")
  3. Copy-and-paste the following code for the URL
1javascript: (function () {
2  const htmlElement = document.querySelector('html');
3  const currentFontSize = htmlElement.style.getPropertyValue('font-size');
4  const isZoomed = currentFontSize === '200%';
5  const newFontSize = isZoomed ? null : '200%';
6  htmlElement.style.setProperty('font-size', newFontSize);
7})();
8
Back to Top