Skip to main content

Cornell University

Web Accessibility Reviews

Important letter spacing in style attributes is wide enough

Applicability

This rule applies to any [HTML element][] with one or more [visible][] [text node][] children, when all the following are true for the letter-spacing property of the element:

  • the [specified][] value is [declared][] in a style attribute; and
  • the [computed][] value is [important][].

Expectation

For each test target, the [computed][] value of its letter-spacing property is at least 0.12 times the [computed][] value of its font-size property.

Assumptions

  • There is no mechanism available on the page to adjust letter-spacing. If there is such a mechanism, it is possible to fail this rule while [Success Criterion 1.4.12 Text Spacing][sc1412] is still satisfied.

  • The font size is constant for all text in 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. This is untested by the current rule.

  • This rule assumes that 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). Thus, the actual space between letters can be larger than the value of the letter-spacing property. If [Success Criterion 1.4.12 Text Spacing][sc1412] is concerned by the actual space between letters, then this rule may fail (with the letter-spacing property being too small) while the Success Criterion is still satisfied (with the actual space being enough).

  • This rule assumes that when inter-letters space is changed because of justification, the letter-spacing property is not changed. Therefore, whether a text is justified or not doesn't change the result of this rule. Note that justifying text is a failure of [Success Criterion 1.4.8 Visual Presentation][sc148].

  • The target text node expresses something in a human language written in a script 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.

Background

Styles [declared][] in a style attribute have higher [cascade specificity][] than any selector; therefore, they "win" the [cascade sort] over any other style from [author origin][], i.e. it cannot be overridden by any of these. On the other hand, if such a style is [declared][] in a style sheet, it can still "lose" the [cascade sort][] to declarations with higher [specificity][] or simply coming from a later style sheet (such as ones injected by assistive technologies). This rule ensures that the element is not in the first case and that the style can be overridden by users, unless it is already at least the minimum required threshold. [Important][] styles that are declared with the [user][user origin] or [user agent][user agent origin] can win the [cascade sort][] over styles with the [author origin][].

CSS specifications define each declaration as being either [important][] (if it has the !important annotation) or [normal][]. Given that normal is also a keyword for some properties, and that !important is wider known than this distinction, this rule rather uses "[important][]"/"not [important][]" to avoid confusion.

Bibliography

About test cases

Test cases descriptions abusively refer to the CSS properties of text nodes, meaning the one of their parent.

Test Cases

Passed

Passed Example 1

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

<p style="letter-spacing: 0.15em !important">
	The toy brought back fond memories of being lost in the rain forest.
</p>

Passed Example 2

This p element has a [computed][] letter-spacing of 3px, which is exactly 0.12 the font-size of 25px.

<style>
	p {
		font-size: 25px;
	}
</style>

<p style="letter-spacing: 3px !important">
	The toy brought back fond memories of being lost in the rain forest.
</p>

Passed Example 3

This p element has two [declared][] values for its letter-spacing property. The latest wins the [cascade sort][]. It has a value of 0.15em, which is wide enough.

<p style="letter-spacing: 0.1em !important; letter-spacing: 0.15em !important">
	The toy brought back fond memories of being lost in the rain forest.
</p>

Passed Example 4

This p element has two [declared][] values for its letter-spacing property. The one which is [important][] wins the [cascade sort][]. It has a value of 0.15em, which is wide enough.

<p style="letter-spacing: 0.15em !important; letter-spacing: 0.1em">
	The toy brought back fond memories of being lost in the rain forest.
</p>

Passed Example 5

This p element has a [computed][] letter-spacing of 2px, 0.2 times its [computed][] font-size of 10px; the div element has no [visible][] text node children.

<div style="font-size: 16px; letter-spacing: 2px !important">
	<p style="font-size: 10px;">
		The toy brought back fond memories of being lost in the rain forest.
	</p>
</div>

Passed Example 6

This p element has a [computed][] letter-spacing of 0.2 times its font-size; the div element has no [visible][] text node children.

<div style="letter-spacing: 0.1em !important">
	<p style="letter-spacing: 0.2em !important;">
		The toy brought back fond memories of being lost in the rain forest.
	</p>
</div>

Failed

Failed Example 1

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 toy brought back fond memories of being lost in the rain forest.
</p>

Failed Example 2

This p element has a [computed][] letter-spacing of 2px which is only 0.1 times the font size (20px), thus below the required minimum.

<style>
	p {
		font-size: 20px;
	}
</style>

<p style="letter-spacing: 2px !important">
	The toy brought back fond memories of being lost in the rain forest.
</p>

Failed Example 3

This p element has a [computed][] letter-spacing of 0.

<p style="letter-spacing: normal !important">
	The toy brought back fond memories of being lost in the rain forest.
</p>

Failed Example 4

This p element has a [computed][] letter-spacing of 0.

<p style="letter-spacing: initial !important">
	The toy brought back fond memories of being lost in the rain forest.
</p>

Inapplicable

Inapplicable Example 1

There is no HTML element.

<svg xmlns="http://www.w3.org/2000/svg">
    <text y="20" style="letter-spacing: 0.1em">ACT rules</text>
</svg>

Inapplicable Example 2

There is no text node.

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

Inapplicable Example 3

There is no [visible][] text node because of display: none.

<p style="display: none; letter-spacing: 0.1em !important;">
	The toy brought back fond memories of being lost in the rain forest.
</p>

Inapplicable Example 4

There is no [visible][] text node because it is positioned off-screen.

<p style="position: absolute; top: -999em; letter-spacing: 0.1em !important;">
	The toy brought back fond memories of being lost in the rain forest.
</p>

Inapplicable Example 5

This p element's letter-spacing property is not [declared][] in a style attribute.

<p style="width: 60%">
	The toy brought back fond memories of being lost in the rain forest.
</p>

Inapplicable Example 6

The [specified][] value of the letter-spacing property of this p element is [declared][] in the style sheet, not in the style attribute (it wins the [cascade sort][] because it is [important][]).

<style>
	p {
		letter-spacing: 0.1em !important;
	}
</style>

<p style="letter-spacing: 0.15em">
	The toy brought back fond memories of being lost in the rain forest.
</p>

Inapplicable Example 7

This p element does not have an [important][] [computed][] letter-spacing.

<p style="letter-spacing: 0.1em">
	The toy brought back fond memories of being lost in the rain forest.
</p>

Inapplicable Example 8

The [computed][] value of the letter-spacing property of this span element is the [inherited][] value, that is the [computed][] value of the p element and therefore not [important][]; the p element has no [visible][] text node children.

<p style="letter-spacing: 0.1em">
	<span style="letter-spacing: inherit !important;">
		The toy brought back fond memories of being lost in the rain forest.
	</span>
</p>

Inapplicable Example 9

The [computed][] value of the letter-spacing property of this span element is the [inherited][] value, that is the [computed][] value of the p element and therefore not [important][]; the p element has no [visible][] text node children.

<p style="letter-spacing: 0.1em">
	<span style="letter-spacing: unset !important;">
		The toy brought back fond memories of being lost in the rain forest.
	</span>
</p>

AI Prompt