Letter spacing fixed with !important
text-spacing/letter-important
- WCAG success criterion
- 1.4.12 (level AA)
- Outcome class
- Automatic. An automated check that can report a confirmed violation.
- Area
- Accessibility, Visual Presentation
- Default severity
- medium
- axe-core rule
text-spacing/letter-important
Why we flag this
Users cannot increase letter spacing for readability.
letter-spacing below 0.12em set with !important in a style attribute.
What the rule checks
Scope. Rendered elements with text whose style attribute sets letter-spacing with !important to a value other than inherit, unset, revert or revert-layer.
Expectation. Fails when that value is below 0.12 times the font size: an author declaration with !important in the style attribute wins over every author style sheet, including the one a text-spacing bookmarklet or extension injects, so the letter spacing (tracking) 1.4.12 requires cannot be set. 0.1em or 2px at a 20px font fails; exactly 0.12em passes. A later declaration without !important does not change the effective value. inherit, unset and revert take over a value not fixed here and do not count; a value without !important can be overridden and does not apply. When layout decides whether the text is affected (the element or an ancestor is positioned absolute/fixed, the font size a px value is compared with is not given in px, or for line height a horizontally scrolling ancestor), the finding is a review, not a violation. Text that is not rendered (display: none) is out of scope. Reported once per element.
Source. WCAG 2.2 SC 1.4.12 Text Spacing (letter spacing (tracking) at least 0.12 times the font size); CSS Cascade 4 (author !important in a style attribute); ACT 24afc2
Detection: shared; needs dom, stylesheets.
Failing example
The check reports a violation here. Corpus case visual_text_spacing_important, element p#letter. The page may contain further findings for other rules.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Opening hours - Town library</title>
<style>
body { color: #111111; background: #ffffff; font-size: 16px; }
</style>
</head>
<body>
<header>
<a href="#main" style="display: inline-block; min-width: 44px; min-height: 44px; line-height: 44px; padding: 0 8px">Skip to main content</a>
<p>Town library</p>
<nav aria-label="Main"><a href="#main" aria-current="page" style="display: inline-block; min-width: 44px; min-height: 44px; line-height: 44px; padding: 0 8px">Overview</a></nav>
</header>
<main id="main">
<h1>Opening hours</h1>
<!-- Fixed below the 1.4.12 values with !important in the style attribute:
a user style sheet cannot increase the spacing. -->
<p id="letter" style="letter-spacing: 0.1em !important">The library is open Monday to Friday from 9:00 to 18:00.</p>
<p id="word" style="word-spacing: normal !important">On Saturday it opens from 10:00 to 14:00.</p>
<p id="line" style="line-height: 120% !important">On public holidays the library stays closed.</p>
<!-- Positioned out of the flow: without layout it is open whether the
text is visible at all. -->
<p id="letter-positioned" style="position: absolute; top: -999em; letter-spacing: 0.1em !important">Books can be returned at the drop box.</p>
</main>
<footer><p>Footer text</p></footer>
</body>
</html>Passing example
The check passes here and reports nothing. Corpus case visual_text_spacing_important_ok. The page may contain further findings for other rules.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Opening hours - Town library</title>
<style>
body { color: #111111; background: #ffffff; font-size: 16px; }
</style>
</head>
<body>
<header>
<a href="#main" style="display: inline-block; min-width: 44px; min-height: 44px; line-height: 44px; padding: 0 8px">Skip to main content</a>
<p>Town library</p>
<nav aria-label="Main"><a href="#main" aria-current="page" style="display: inline-block; min-width: 44px; min-height: 44px; line-height: 44px; padding: 0 8px">Overview</a></nav>
</header>
<main id="main">
<h1>Opening hours</h1>
<!-- Exactly the 1.4.12 values, fixed with !important: a user needs no more. -->
<p id="letter" style="letter-spacing: 0.12em !important">The library is open Monday to Friday from 9:00 to 18:00.</p>
<p id="word" style="word-spacing: 0.16em !important">On Saturday it opens from 10:00 to 14:00.</p>
<p id="line" style="line-height: 1.5 !important">On public holidays the library stays closed.</p>
<!-- The later declaration without !important does not win over the first. -->
<p id="overridden" style="letter-spacing: 0.15em !important; letter-spacing: 0.1em">Books can be returned at the drop box.</p>
<!-- inherit takes over a value that is not fixed here. -->
<p style="word-spacing: 0.2em"><span id="inherited" style="word-spacing: inherit !important">The reading room closes thirty minutes earlier.</span></p>
</main>
<footer><p>Footer text</p></footer>
</body>
</html>This page is generated from the rule catalogue and the rule contracts; see therule overview for how the outcome classes are derived.