惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园_首页
GbyAI
GbyAI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Apple Machine Learning Research
Apple Machine Learning Research
大猫的无限游戏
大猫的无限游戏
阮一峰的网络日志
阮一峰的网络日志
Last Week in AI
Last Week in AI
V
Visual Studio Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
The Cloudflare Blog
博客园 - 【当耐特】
博客园 - 叶小钗
量子位
博客园 - 聂微东
S
SegmentFault 最新的问题
美团技术团队
Hugging Face - Blog
Hugging Face - Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
月光博客
月光博客
宝玉的分享
宝玉的分享
小众软件
小众软件
罗磊的独立博客
有赞技术团队
有赞技术团队
Stack Overflow Blog
Stack Overflow Blog

Stefan Judis Web Development

Web Weekly #199 Web Weekly #198 Web Weekly #197 Michelle Barker on Stage Fright Web Weekly #196 Escape from Average Web Weekly #195 Web Weekly #194 Web Weekly #193 Web Weekly #192 Web Weekly #191 Web Weekly #190 Web Weekly #189 Web Weekly #188 Intl can localize units, too! The scope of type guards and assertion functions Web Weekly #187 Web Weekly #186 Web Weekly #185 New lines are removed from WHATWG URLs Web Weekly #184 Nobody owes you anything How to scale elements and their layout with CSS "zoom" Notes on relying on the ARIA Authoring Practices Guide Web Weekly #183 Web Weekly #182 How to style the found search / "find in page" substrings Web Weekly #181 Web Weekly #180 Clean up your Mac with open source
ARIA roles can remove their children’s semantics
Stefan Judis · 2026-01-13 · via Stefan Judis Web Development

I've learned something new about ARIA today!

You probably know the first rule of ARIA:

If you can use a native HTML element or attribute with the semantics and behavior you require already built in, instead of repurposing an element and adding an ARIA role, state, or property to make it accessible, then do so.

Unfortunately, many people slap ARIA attributes on elements without really understanding what they're doing. Adding role="menu" to navigation lists is one example that I see very often.

What's supposed to be a menu? Here's the ARIA spec:

A menu is a container, generally rendered as a popup or overlay, for a set of menu items that can be invoked to perform an action or function.

Making a list of navigation entries a menu isn't a good idea because a menu is supposed to include menu items that invoke actions or functions. However, that's not all.

Today I learned that adding ARIA attributes to elements can also change the semantics of the included elements. Here's the role="menu" example for a ul case.

<ul>
  <li>Item 1</li>
  <li>Item 2</li>
  <li>Item 3</li>
</ul>

Accessibility Tree

list

  • listitem
  • listitem
  • listitem

A "normal" list might be announced by a screen reader as "List (3 items)". It's helpful to know how many elements are in the list, right? A menu, though, must include menu items. And if you're not planning to also add elements with role="menuitem" to the menu, it'll be empty.

I quickly tested Chrome with VoiceOver on this CodePen:

  • A normal list is announced as "List (3 items)".
  • A list with role="menu" without included menuitems isn't announced at all. The list entries are read out loud.
  • A list with role="menu" with included menuitems is announced as "Menu (3 items)".

Incorrect role="menu" usage can not only be confusing but might remove the list item count and nuke the item semantics.

Don't mess with ARIA unless you know what you're doing.

Check this post if you want to dive deeper into ARIA and what other roles affect their children semantics.