Skip to main content

Cornell University

Web Accessibility Reviews

Menuitem has non-empty accessible name

Applicability

This rule applies to [HTML elements][] that is a [semantic][semantic role] menuitem [included in the accessibility tree][].

Expectation

Each target element has an [accessible name][] that is not empty ("").

Assumptions

This rule assumes that all menuitems are user interface components as defined by WCAG 2. If an element has a role of menuitem that would not be perceived as a single control by users, 4.1.2 Name, Role, Value would not apply and so failing this rule would not result in a conformance issue.

Accessibility Support

Implementation of [Presentational Roles Conflict Resolution][] varies from one browser or assistive technology to another. Depending on this, some [semantic][semantic role] menuitem elements can fail this rule with some technology but users of other technologies would not experience any accessibility issue.

Background

Bibliography

Test Cases

Passed

Passed Example 1

This element with the menuitem role has an [accessible name][] because of its text content.

<div role="menu">
	<button role="menuitem">New file</button>
</div>

Passed Example 2

This element with the menuitem role has an [accessible name][] because of its aria-label attribute.

<div role="menu">
	<button role="menuitem" aria-label="New file">
		<img src="/test-assets/shared/file.svg" alt="" />
	</button>
</div>

Passed Example 3

This element with the menuitem role has an [accessible name][] because its aria-labelledby attribute references an element with text content.

<div role="menu">
	<button role="menuitem" aria-labelledby="newfile">
		<img src="/test-assets/shared/file.svg" alt="" />
		<span id="newfile" hidden>New file</span>
	</button>
</div>

Passed Example 4

This element with the menuitem role has an [accessible name][] because of its title attribute.

<div role="menu">
	<button role="menuitem" title="New file">
		<img src="/test-assets/shared/file.svg" alt="" />
	</button>
</div>

Failed

Failed Example 1

This element with the menuitem role has no [accessible name][] because it has no content or attribute that can provide it.

<div role="menu">
	<button role="menuitem">
		<img src="/test-assets/shared/file.svg" alt="" />
	</button>
</div>

Failed Example 2

This off-screen element with the menuitem role has no [accessible name][] because it has no content or attribute that can provide it.

<html lang="en">
	<style>
		.offscreen {
			position: absolute;
			left: -9999px;
			top: -9999px;
		}
	</style>
	<div role="menu" class="offscreen">
		<button role="menuitem">
			<img src="/test-assets/shared/file.svg" alt="" />
		</button>
	</div>
</html>

Inapplicable

Inapplicable Example 1

The li element has a listitem [semantic role][], even as a child of a menu element.

<menu>
	<li>
		<a href="#">New file</a>
	</li>
</menu>

Inapplicable Example 2

This element with the menuitem role does not need an [accessible name][] because it is not [included in the accessibility tree][].

<div role="menu" hidden>
	<button role="menuitem">
		<img src="/test-assets/shared/file.svg" alt="" />
	</button>
</div>

AI Prompt