Ensuring Accessible Inline Spacing in Text
Rule ID: avoid-inline-spacing
Ruleset: axe-core 4.10
User Impact: Serious
Guidelines: WCAG 2.1 (AA), WCAG 2.2 (AA), EN 301 549
How to Fix the Problem
To comply with the avoid-inline-spacing
rule, inline styles applied to text must allow user agents (e.g., browsers or assistive technologies) to override them with custom stylesheets. This ensures users who need specific text spacing—such as individuals with dyslexia or other cognitive disabilities—can modify the spacing for better readability.
✅ Correct Examples
Use inline styles that define spacing properties without using !important
, so they can be overridden:
❌ Incorrect Examples
Avoid using !important
in spacing styles, as it prevents user stylesheets from overriding them:
Why it Matters
Users with cognitive disabilities, especially those who experience issues tracking text, rely on adjusted spacing for better legibility. If text spacing is rigid due to !important
declarations, these users cannot apply their preferred stylesheets or browser settings, significantly hampering their reading experience.
Allowing user agents to override styles supports flexibility, inclusivity, and adherence to WCAG 2.1/2.2 guidelines, especially Success Criterion 1.4.12 (Text Spacing).
Rule Description
This rule ensures that inline styles for spacing (line-height, word-spacing, letter-spacing, font-size) do not include !important
declarations. The intent is to make these styles easily overrideable by custom user stylesheets, which is essential for accessibility.
The Algorithm (in Simple Terms)
-
Check all inline styles on text elements.
-
If a style uses spacing properties (
line-height
,letter-spacing
,word-spacing
) and includes!important
, it fails. -
If the properties are defined without
!important
, it passes. -
Negative or excessively restrictive values may also contribute to a failure if they hinder readability.