Testing the menu element
The <menu> element is described in the HTML specification as a semantic alternative to <ul>, but treated by browsers (and exposed through the accessibility tree) as no different than <ul>. It represents an unordered list of items (which are represented by <li> elements).
The key difference is that <ul> primarily contains items for display, while <menu> was intended for interactive items.
The related <menuitem> element has been deprecated.
Example
<menu>
<li><button>Inject Hello</button></li>
<li><button>Inject Goodbye</button></li>
<li><button>Clear</button></li>
</menu>
<div class="menu-example" aria-live="polite">
<!-- Visible message -->
</div>
<div class="announcement" aria-live="polite">
<!-- Message for screen readers -->
</div>
Expected results for screen readers
- The
<menu>element should be announced as a list (for example, "list, 3 items") when the screen reader enters it. It should not be announced as a menu - All button names should be announced
- Activating "Inject Hello" should present "Hello world" into container below
- The injected information should be announced to screen readers
- Activating "Inject Goodbye" should present "Goodbye world" into container below
- The injected information should be announced to screen readers
- Activating the "Clear" button should clear any information from the container below
- "Your message has been cleared" should be announced