Zoomed text node is not clipped with CSS overflow

  • Rule Type:atomic
  • Rule Id: 59br37
  • Last modified: Jun 23, 2022
  • Accessibility Requirements Mapping:
    • 1.4.4 Resize text (Level AA)
      • Learn More about 1.4.4 Resize text
      • Required for conformance to WCAG 2.0 and later on level AA and higher.
      • Outcome mapping:
        • Any failed outcomes: success criterion is not satisfied.
        • All passed outcomes: success criterion needs further testing.
        • An inapplicable outcome: success criterion needs further testing.
  • Input Aspects:

Description

This rule checks that text nodes are not unintentionally clipped by overflow, when a page is zoomed to 200% on 1280 by 1024 viewport;

Applicability

This rule applies to any text node for which all of the following is true when in a viewport size of 640 by 512:

Note: A viewport size of 640 by 512 is equivalent to a viewport size of 1280 by 1024 zoomed 200%.

Expectation 1

Each test target is not horizontally clipped by overflow of an ancestor in the flat tree when in a viewport size of 640 by 512, except if the clipping ancestor has a computed white-space of nowrap, and a computed text-overflow that is not clip

Expectation 2

Each test target is not vertically clipped by overflow of an ancestor in the flat tree when in a viewport size of 640 by 512, except if the clipping ancestor has a used line-height equal to or greater than the height of its bounding box, or in case of a computed overflow-y of clip, its content box.

Assumptions

If any of the following assumptions is true, failing this rule may not result in a failure of success criterion 1.4.4 Resize text:

  • There is no other mechanism for resizing text available on the page, that can be used to resize text to 200% without loss of information or functionality. This includes font resizing in the browser, or a javascript mechanism of resizing in the page.
  • Text nodes can not be horizontally or vertically clipped by overflow without loss of information, except for text nodes with an ancestor with aria-hidden set to true, or when specific styles have been applied to ensure text is clipped cleanly (text-overflow, line wrapping or hidden text).
  • While success criterion 1.4.4 Resize text does not explicitly mention which viewport size has to be resized up to 200%, it is assumed that a viewport size of 1280 by 1024 is applicable. A 1280 by 1024 viewport size is explicitly mentioned under success criterion 1.4.10 Reflow.

Accessibility Support

Some user agents treat the value of the aria-hidden attribute as case-sensitive.

Background

When the computed value of the line-height property is normal, the used value depends on font specific metrics. CSS specifications recommend that the used value is between 1.0 and 1.2 and major browsers are effectively using values close to 1.2.

Bibliography

Test Cases

Passed

Passed Example 1

Open in a new tab

This text node is fully visible at a viewport size of 640 by 512.

<div style="white-space: nowrap; overflow: hidden; font-size: 16px;">
	Once upon a midnight dreary, while I pondered, weak and weary,<br />
	Over many a quaint and curious volume of forgotten lore.<br />
	While I nodded, nearly napping, suddenly there came a tapping,<br />
	As of some one gently rapping, rapping at my chamber door.<br />
	“’Tis some visitor,” I muttered, “tapping at my chamber door.<br />
	Only this and nothing more.”
</div>

Passed Example 2

Open in a new tab

This text node is horizontally clipped using text-overflow: ellipsis at a viewport size of 640 by 512. A link to a full version of the poem is also provided.

<div style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 16px;">
	Once upon a midnight dreary, while I pondered, weak and weary, Over many a quaint and curious volume of forgotten
	lore. While I nodded, nearly napping, suddenly there came a tapping.
</div>
<a href="/test-assets/59br37/poem.html">Full text of the poem</a>

Passed Example 3

Open in a new tab

This text node is restricted to a single line, by setting a line-height that is the same as the height. A link to a full version of the poem is also provided.

<style>
	.wordClip {
		overflow: hidden;
		word-wrap: break-word;
		height: 16px;
		line-height: 16px;
		font-size: 16px;
	}
</style>
<div class="wordClip">
	Once upon a midnight dreary, while I pondered, weak and weary, Over many a quaint and curious volume of forgotten
	lore. While I nodded, nearly napping, suddenly there came a tapping.
</div>
<a href="/test-assets/59br37/poem.html">Full text of the poem</a>

Passed Example 4

Open in a new tab

This text node is not vertically clipped with overflow: hidden because it has a parent with overflow: auto at a viewport size of 640 by 512.

<div style="overflow: hidden; height: 2em; font-size: 16px;">
	<div style="overflow: auto; height: 2em;">
		Once upon a midnight dreary, while I pondered, weak and weary, Over many a quaint and curious volume of forgotten
		lore. While I nodded, nearly napping, suddenly there came a tapping.
	</div>
</div>

Failed

Failed Example 1

Open in a new tab

This text node is vertically clipped because it has a fixed height that does not leave enough space for the content to wrap.

<div style="overflow: hidden; height: 1.5em; font-size: 16px;">
	Once upon a midnight dreary, while I pondered, weak and weary, Over many a quaint and curious volume of forgotten
	lore. While I nodded, nearly napping, suddenly there came a tapping.
</div>

Failed Example 2

Open in a new tab

This text node is vertically clipped because its height is relative to the viewport height, leaving insufficient space for the page to be zoomed to 200% at a viewport size of 1280 by 1024.

<div style="overflow: hidden; height: 16vh; font-size: 16px;">
	Once upon a midnight dreary, while I pondered, weak and weary,<br />
	Over many a quaint and curious volume of forgotten lore.<br />
	While I nodded, nearly napping, suddenly there came a tapping,<br />
	As of some one gently rapping, rapping at my chamber door.<br />
	“’Tis some visitor,” I muttered, “tapping at my chamber door.<br />
	Only this and nothing more.”
</div>

Failed Example 3

Open in a new tab

This text node is vertically clipped by style that is applied at a viewport size width of 640.

<style>
	@media screen and (max-width: 640px) {
		.myContainer {
			height: 1.5em;
			width: 50%;
			overflow: hidden;
			font-size: 16px;
		}
	}
</style>
<div class="myContainer">
	Once upon a midnight dreary, while I pondered, weak and weary, Over many a quaint and curious volume of forgotten
	lore. While I nodded, nearly napping, suddenly there came a tapping, As of some one gently rapping, rapping at my
	chamber door. “’Tis some visitor,” I muttered, “tapping at my chamber door. Only this and nothing more.”
</div>

Failed Example 4

Open in a new tab

This text node is vertically clipped at a viewport size of 640 by 512.

<div style="overflow-y: hidden; height: 10px; white-space: nowrap; text-overflow: ellipsis; font-size: 16px;">
	Once upon a midnight dreary, while I pondered, weak and weary, Over many a quaint and curious volume of forgotten
	lore. While I nodded, nearly napping, suddenly there came a tapping.
</div>

Failed Example 5

Open in a new tab

This text node is horizontally clipped at a viewport size of 640 by 512.

<style>
	.wordClip {
		overflow-x: hidden;
		white-space: nowrap;
		text-overflow: clip;
		width: 50px;
		height: 16px;
		line-height: 16px;
		font-size: 16px;
	}
</style>
<div class="wordClip">
	Once upon a midnight dreary, while I pondered, weak and weary, Over many a quaint and curious volume of forgotten
	lore. While I nodded, nearly napping, suddenly there came a tapping.
</div>

Inapplicable

Inapplicable Example 1

Open in a new tab

This text node is not visible at a viewport size of 640 by 512.

<p style="display:none;">Last updated 2020/03/27 10:52pm</p>

Inapplicable Example 2

Open in a new tab

This text node has an SVG element as a parent.

<svg>
	<text x="0" y="15">I love SVG!</text>
</svg>

Inapplicable Example 3

Open in a new tab

This text node has no ancestor with overflow: hidden or clip.

<div style="overflow: auto; height: 1.5em; font-size: 16px;">
	Once upon a midnight dreary, while I pondered, weak and weary, Over many a quaint and curious volume of forgotten
	lore. While I nodded, nearly napping, suddenly there came a tapping.
</div>

Inapplicable Example 4

Open in a new tab

This text node has an ancestor with aria-hidden set to true.

<img src="/test-assets/shared/w3c-logo.png" alt="W3C logo" /> <span aria-hidden="true">(W3C Logo)</span>

Inapplicable Example 5

Open in a new tab

This text node with the text "Web Content Accessibility Guidelines 2.1" is fully hidden in a viewport size of 640 by 512.

<style>
	@media screen and (max-width: 640px) {
		.mobile-hidden {
			position: absolute;
			width: 1px;
			height: 1px;
			overflow: hidden;
			font-size: 16px;
		}
	}
</style>
<a href="/"> Next<span class="mobile-hidden">: Web Content Accessibility Guidelines 2.1</span> </a>

Glossary

Attribute value

The attribute value of a content attribute set on an HTML element is the value that the attribute gets after being parsed and computed according to specifications. It may differ from the value that is actually written in the HTML code due to trimming whitespace or non-digits characters, default values, or case-insensitivity.

Some notable case of attribute value, among others:

  • For enumerated attributes, the attribute value is either the state of the attribute, or the keyword that maps to it; even for the default states. Thus <input type="image" /> has an attribute value of either Image Button (the state) or image (the keyword mapping to it), both formulations having the same meaning; similarly, "an input element with a type attribute value of Text" can be either <input type="text" />, <input /> (missing value default), or <input type="invalid" /> (invalid value default).
  • For boolean attributes, the attribute value is true when the attribute is present and false otherwise. Thus <button disabled>, <button disabled="disabled"> and <button disabled=""> all have a disabled attribute value of true.
  • For attributes whose value is used in a case-insensitive context, the attribute value is the lowercase version of the value written in the HTML code.
  • For attributes that accept numbers, the attribute value is the result of parsing the value written in the HTML code according to the rules for parsing this kind of number.
  • For attributes that accept sets of tokens, whether space separated or comma separated, the attribute value is the set of tokens obtained after parsing the set and, depending on the case, converting its items to lowercase (if the set is used in a case-insensitive context).
  • For aria-* attributes, the attribute value is computed as indicated in the WAI-ARIA specification and the HTML Accessibility API Mappings.

This list is not exhaustive, and only serves as an illustration for some of the most common cases.

The attribute value of an IDL attribute is the value returned on getting it. Note that when an IDL attribute reflects a content attribute, they have the same attribute value.

Horizontally Clipped by Overflow

A node is Horizontally Clipped by Overflow if it has an ancestor in the flat tree with a computed overflow-x of hidden or clip, where changing the overflow-x of all such ancestors to visible would cause more of the node to become visible.

Example of Horizontally Clipped by Overflow for Horizontally Clipped by Overflow

This img element has an ancestor div element with an overflow-x of hidden. The width of the img is greater than that of the ancestor div, and so is clipped by the overflow-x property of the div.

<div style="width: 100px; overflow-x: hidden;">
	<img src="/test-assets/shared/w3c-logo.png" width="150" alt="Partial W3C Logo" />
</div>

Namespaced Element

An element with a specific namespaceURI value from HTML namespaces. For example an "SVG element" is any element with the "SVG namespace", which is http://www.w3.org/2000/svg.

Namespaced elements are not limited to elements described in a specification. They also include custom elements. Elements such as a and title have a different namespace depending on where they are used. For example a title in an HTML page usually has the HTML namespace. When used in an svg element, a title element has the SVG namespace instead.

Outcome

An outcome is a conclusion that comes from evaluating an ACT Rule on a test subject or one of its constituent test target. An outcome can be one of the three following types:

  • Inapplicable: No part of the test subject matches the applicability
  • Passed: A test target meets all expectations
  • Failed: A test target does not meet all expectations

Note: A rule has one passed or failed outcome for every test target. When there are no test targets the rule has one inapplicable outcome. This means that each test subject will have one or more outcomes.

Note: Implementations using the EARL10-Schema can express the outcome with the outcome property. In addition to passed, failed and inapplicable, EARL 1.0 also defined an incomplete outcome. While this cannot be the outcome of an ACT Rule when applied in its entirety, it often happens that rules are only partially evaluated. For example, when applicability was automated, but the expectations have to be evaluated manually. Such "interim" results can be expressed with the incomplete outcome.

Vertically Clipped by Overflow

A node is Vertically Clipped by Overflow if it has an ancestor in the flat tree with a computed overflow-y of hidden or clip, where changing the overflow-y of all such ancestors to visible would cause more of the node to become visible.

Example of Vertically Clipped by Overflow for Vertically Clipped by Overflow

This img element has an ancestor div element with an overflow-y of hidden. The height of the img is greater than that of the ancestor div, and so is clipped by the overflow-y property of the div.

<div style="height: 100px; overflow-y: hidden;">
	<img src="/test-assets/shared/w3c-logo.png" height="150" alt="Partial W3C Logo" />
</div>

Visible

Content perceivable through sight.

Content is considered visible if making it fully transparent would result in a difference in the pixels rendered for any part of the document that is currently within the viewport or can be brought into the viewport via scrolling.

Content is defined in WCAG.

For more details, see examples of visible.

viewport size

The viewport size is the width and height at which a page is rendered. The viewport size is equal to the innerWidth and innerHeight of the window of the top-level browsing context.

Note: The viewport size is not to be confused with the "resolution" of the operating system. Often a browser will be a single window in the operating system, with a width and height different from the resolution of the operating system. Often browsers also include additional user interface components, such as a URL bar, tab bar, and a bookmarks bar. None of these are included in the viewport size. In full screen mode the viewport size might be the same as the resolution of the operating system.

Note: The viewport size includes, if rendered, all scrollbars.


Useful Links


Implementations

This section is not part of the official rule. It is populated dynamically and not accounted for in the change history or the last modified date. This section will not be included in the rule when it is published on the W3C website.

ToolConsistencyCompleteReport
QualWebconsistentYesView Report

Acknowledgments

Funding

  • WAI-Tools

Assets

  • The Raven, poem by Edgar Allan Poe
Table of Contents