EA-R53
<iframe> has negative tabindex
This rule is an error and tests the following accessibility guidelines:
Description
This rule checks that iframe
elements with a negative tabindex
attribute value contain no interactive elements.
Explanation
<iframe> elements with a negative tabindex attribute must not contain interactive elements. By setting the tabindex attribute value of an iframe element to -1 or some other negative number, it becomes impossible to move the focus into the browsing context of the iframe element.
Expectation 1
For each test target, the nested browsing context does not contain elements that are visible and part of the sequential focus navigation.
Expectation 2
An element is contained in a nested browsing context if its owner document is the container document of the nested browsing context.
Assumptions
This rule assumes that interactive content inside iframe
elements is used to provide functionality. If the interactive content does not provide functionality, for example a button that does nothing when clicked, success criterion 2.1.1 may be satisfied, even if the rule is failed.
Accessibility Support
There are no major accessibility support issues known for this rule.
Background
By setting the tabindex
attribute value of an iframe
element to -1
or some other negative number, it becomes impossible to move the focus into the browsing context of the iframe
element. Even though its content is still included in the sequential focus navigation, there is no way to move the focus to any of the items in the iframe
using standard keyboard navigation.
Tip
Remove the negative tabindex if the <iframe> contains focusable elements.
Examples
Passed
Example 1 - Passed
This iframe
element contains no content that is part of sequential focus navigation.
<iframe tabindex="-1" srcdoc="<h1>Hello world</h1>"></iframe>
Example 2 - Passed
This iframe
element contains a link that is not part of sequential focus navigation because of its tabindex
.
<iframe tabindex="-1" srcdoc="<a href='/' tabindex='-1'>Home</a>"></iframe>
Example 3 - Passed
This iframe
element contains no visible content because of the small size of the iframe.
<iframe tabindex="-1" width="1" height="1" srcdoc="<a href='/'>Home</a>"></iframe>
Example 4 - Passed
This iframe
element contains no visible content because the iframe is hidden.
<iframe tabindex="-1" hidden srcdoc="<a href='/'>Home</a>"></iframe>
Failed
Example 1 - Failed
This iframe
element has a link that is part of sequential focus navigation.
<iframe tabindex="-1" srcdoc="<a href='/'>Home</a>"></iframe>
Inapplicable
Example 1 - Inapplicable
This iframe
element does not have a tabindex
attribute value that is a negative number
<iframe tabindex="0" srcdoc="<a href='/'>Home</a>"></iframe>
Acknowledgments
This document includes material copied from or derived from https://www.w3.org/WAI/standards-guidelines/act/rules/4b1c6c/. Copyright © 2023 W3C® (MIT, ERCIM, Keio, Beihang).