SIA-R91!important letter spacing in style attribute is wide enough

Accessibility requirements

This rule tests conformance of the following accessibility requirements:

Description

This rule checks that the style attribute is not used to prevent adjusting letter-spacing by using !important, except if it's at least 0.12 times the font size.

Applicability

This rule applies to every element in the HTML namespace with a visible text node child, when all the following are true for the letter-spacing property of the element:

The property can be declared on an ancestor of the test target.

Expectation

  1. The computed value of the letter-spacing property of the target element is at least 0.12 times the computed value of its font-size property.

Assumptions

This rule makes the following assumption:

  • There is no mechanism available on the page to adjust letter-spacing.

  • The font size is constant for all text node children of the element. If font-size changes (e.g., through use of the ::first-line pseudo-element) then the required letter spacing would also change throughout the element.

  • WCAG's meaning for the "Letter spacing style property" is the value of the CSS letter-spacing property rather than the actual space between letters. The value of the CSS property is added to whichever spacing already exist (for example, due to kerning or justification). Thus, the actual space between letters can be larger than the value of the letter-spacing property.

  • The target text nodes children express something in a human language written in a script that that uses the letter-spacing property.

Accessibility support

While some assistive technologies are able to set user origin or user agent origin styles, others, such as browser extensions, are only able to set styles with the author origin. Such assistive technologies cannot create styles "winning" the cascade sort over a style attribute with an important declaration. If accessibility support does not include assistive technologies that override letter-spacing through author origin, this rule should not be used.

Examples

Passed

This <p> element has a computed letter-spacing of 0.15 time the font-size.

<p style="letter-spacing: 0.15em !important">
    The quick brown fox jumps over the lazy dog.
</p>

The <div> element is inapplicable since it does not have any text node children. The <p> element has a computed letter-spacing of 2px, 0.2 times its computed font-size of 10px

<div style="font-size: 16px; letter-spacing: 2px !important">
	<p style="font-size: 10px;">
        The quick brown fox jumps over the lazy dog.
	</p>
</div>

Failed

This <p> element has a computed letter-spacing of only 0.1 times the font size, which is below the required minimum.

<p style="letter-spacing: 0.1em !important">
    The quick brown fox jumps over the lazy dog.
</p>

Inapplicable

The <div> element has no text node children.

<div style="letter-spacing: 0.1em !important;"></div>

This <p> element does not have an important computed letter-spacing.

<p style="letter-spacing: 0.1em">
    The quick brown fox jumps over the lazy dog.
</p>

Acknowledgments

This document includes material copied from or derived from https://www.w3.org/WAI/standards-guidelines/act/rules/24afc2/. Copyright © 2024 W3C® (MIT, ERCIM, Keio, Beihang).