Orientation of the page is not restricted using CSS transform property

  • Rule Type:atomic
  • Rule Id: b33eff
  • Last modified: Jun 23, 2020
  • Accessibility Requirements Mapping:
    • 1.3.4 Orientation (Level: AA)
      • Learn More about 1.3.4 (Orientation)
      • Required for conformance to WCAG 2.1 and above on level AA and above.
      • 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 page content is not restricted to either landscape or portrait orientation using CSS transform property.

Applicability

The rule applies to any HTML element that is visible and has a CSS transform property that is applied conditionally on the orientation media feature with a value of landscape or portrait, where the CSS transform property has any of the below transformation functions:

Note: These specific transformation functions are of interest to this rule as they have the potential to affect the rotation of a given element.

Note: The rotate3d, rotateZ and matrix3d are currently part of a W3C Editor's Draft.

Expectation

The target element is neither rotated clockwise nor counter clockwise around the Z-axis at an angle corresponding to 90 degrees relative from the position of the element in landscape orientation to the position of the element in portrait orientation, and vice versa.

Note: Imagine the display of a smartphone with an upwards pointing arrow at its center. If a user turns the smartphone a quarter turn, that is a move from one orientation to the other, they would want the arrow to continue pointing upwards. The smartphone accomplishes this by rotating the contents of its display a quarter turn to counter the users change in orientation. In effect, the arrow has remained in place and its rotation relative from one orientation to the other is 0 degrees. Now imagine that a developer rotates the arrow by a quarter turn only when in one orientation and not the other; its rotation relative from one orientation to the other would then be 90 degrees and it would appear stuck, or locked, as the user moves between orientations. What the developer has done is effectively counter the smartphones attempt at countering the users change in orientation.

Assumptions

This rule does not consider and may produce incorrect results for:

  • Elements for which a particular display orientation is essential.
  • The existence of any control on the page that can change the orientation on demand.

Accessibility Support

There are no major accessibility support issues known for this rule.

Background

Test Cases

Passed

Passed Example 1

Open in a new tab

A page where CSS transform property has rotateZ transform function conditionally applied on the orientation media feature which does not restrict the element to either portrait or landscape orientation.

<html lang="en">
	<head>
		<title>Page with some content</title>
		<style>
			@media (orientation: portrait) {
				html {
					transform: rotateZ(1turn);
				}
			}
		</style>
	</head>
	<body>
		<main>
			Page Content
		</main>
	</body>
</html>

Passed Example 2

Open in a new tab

A page where CSS transform property has matrix transform function conditionally applied on the orientation media feature which does not restrict the element to either portrait or landscape orientation.

<html lang="en">
	<head>
		<title>Page with some content</title>
		<style>
			@media (orientation: portrait) {
				html {
					transform: matrix(1, -1.22465e-15, 1.22465e-15, 1, 0, 0);
				}
			}
		</style>
	</head>
	<body>
		<main>
			Page Content
		</main>
	</body>
</html>

Failed

Failed Example 1

Open in a new tab

A page where CSS transform property has rotate transform function conditionally applied on the orientation media feature which restricts the element to landscape orientation.

<html lang="en">
	<head>
		<title>Page with some content</title>
		<style>
			@media (orientation: portrait) {
				html {
					transform: rotate(1.5708rad);
				}
			}
		</style>
	</head>
	<body>
		Page Content
	</body>
</html>

Failed Example 2

Open in a new tab

A page where CSS transform property has matrix3d transform function conditionally applied on the orientation media feature which restricts the element to portrait orientation.

<html lang="en">
	<head>
		<title>Page with some content</title>
		<style>
			@media (orientation: landscape) {
				body {
					transform: matrix3d(0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
				}
			}
		</style>
	</head>
	<body>
		Page Content
	</body>
</html>

Failed Example 3

Open in a new tab

This page appears rotated at a slight angle of 2.5 degrees for stylistic purposes, but is locked in portrait orientation by applying a 92.5 degree rotation when in landscape orientation:

<html lang="en">
	<head>
		<title>Page with some content</title>
		<style>
			body {
				transform: rotate(2.5deg);
			}

			@media (orientation: landscape) {
				body {
					transform: rotate(92.5deg);
				}
			}
		</style>
	</head>
	<body>
		Page Content
	</body>
</html>

Inapplicable

Inapplicable Example 1

Open in a new tab

A page where there are no CSS styles.

<html lang="en">
	<head>
		<title>Page with some content</title>
	</head>
	<body>
		I am a page with no styles
	</body>
</html>

Inapplicable Example 2

Open in a new tab

A page that has no CSS transform property specified.

<html lang="en">
	<head>
		<title>Page with some content</title>
		<style>
			html {
				font-size: 22px;
			}
			@media (min-width: 30em) {
				font-size: 100%;
			}
		</style>
	</head>
	<body>
		Page Content
	</body>
</html>

Inapplicable Example 3

Open in a new tab

A page where CSS transform property is applied to an element that is not visible.

<html lang="en">
	<head>
		<title>Page with some content</title>
		<style>
			@media (orientation: lanscape) {
				body {
					transform: rotateZ(0, 0, 1, 270deg);
				}
			}
		</style>
	</head>
	<body style="display:none;">
		<main>
			Page Content
		</main>
	</body>
</html>

Inapplicable Example 4

Open in a new tab

A page where CSS transform property is not applied conditionally on the orientation media feature.

<html lang="en">
	<head>
		<title>Page with some content</title>
		<style>
			body {
				transform: rotate(90deg);
			}
		</style>
	</head>
	<body>
		<main>
			Page Content
		</main>
	</body>
</html>

Inapplicable Example 5

Open in a new tab

A page where CSS transform property is conditionally applied on the orientation media feature, but does not have any of the applicable transformation functions which restricts the element to either landscape or portrait orientation.

<html lang="en">
	<head>
		<title>Page with some content</title>
		<style>
			@media (orientation: portrait) {
				body {
					transform: translateX(100px);
				}
			}
		</style>
	</head>
	<body>
		<main>
			Page Content
		</main>
	</body>
</html>

Glossary

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.

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.

Examples for Visible

Note: The examples presented here are non-normative and not testable. They serve to illustrate some common pitfalls about the definition and to help the implementers of ACT rules understand it.

This span element is visible (by default, elements are visible).

<span>Now you can see me!</span>

This span element is not visible because of the CSS visibility property.

<span style="visibility: hidden">I'm the invisible man</span>

This span element is not visible because of the CSS display property.

<span style="display: none">I'm the invisible man</span>

This span element is not visible because it is positioned off-screen

<span style="position: absolute; top: -9999px; left: -9999px;">Incredible how you can</span>

This span element is not visible because it contains only whitespace and line breaks.

<span>
	<br />
	&nbsp;
</span>

This span element is not visible because it has the exact same color as its background.

<span style="color: #00F; background: #00F;">See right through me</span>

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.

ToolConsitencyCompleteReport
axe-coreconsistentYesView Report
QualWebconsistentYesView Report
AlfaconsistentNoView Report
SortSiteconsistentNoView Report

Acknowledgments

Table of Contents