NeovaNền tảng SEO chuyên sâu

Role ARIA nằm ngoài role cha bắt buộc

Trong Neova Chạy ngay từ lần crawl: không cần thiết lập gì.

Quy tắc được rà soát lần cuối ngày 17 tháng 10 năm 2026 · Hướng dẫn cập nhật ngày 7 tháng 7 năm 2026

WCAG 1.3.1 yêu cầu cấu trúc phải được cung cấp. Một số role chỉ có nghĩa khi nằm trong một phần tử cha, như tab trong tablist. Nằm ngoài đó, trình đọc màn hình không thể truyền đạt cấu trúc.

Bạn có thể làm gì

Di chuyển phần tử vào trong một phần tử có role bắt buộc, hoặc gắn chúng với nhau bằng aria-owns.

Vì sao Neova đánh dấu

  • Các role như tab, listitem hay row chỉ có nghĩa khi nằm trong phần tử cha bắt buộc của chúng.
  • Ra ngoài đó, trình đọc màn hình không nói được mục thuộc về đâu hay có bao nhiêu mục cùng cấp.
  • WCAG 1.3.1 (cấp độ A) yêu cầu cấu trúc phải có sẵn cho công nghệ hỗ trợ.

Nguồn

Hướng dẫn đầy đủ

Phần này tạm thời còn bằng tiếng Anh.

What This Check Flags

Some ARIA roles are only meaningful inside a specific parent role. An option has to live inside a listbox; a tab has to sit inside a tablist; a menuitem belongs to a menu or menubar. When a required-context child is orphaned — sitting under the wrong parent or none at all — this rule fires. The stakes: assistive tech reads roles as a set relationship (“option 3 of 8”), and an orphaned child breaks that counting entirely, leaving screen-reader users unable to tell where they are in the widget.

Think of these roles like puzzle pieces cut to fit one slot. A tab only means “tab” because a tablist is standing behind it saying “this is one of my tabs.” Pull the piece out of its slot and it’s just a shape — the screen reader can still see a role sitting there, but it has lost the context that makes the role useful. That’s why a lone role="option" in a stray <div> is arguably worse than no role at all: it promises a listbox relationship that isn’t there.

A Real Failing Snippet, and the Fix

This is the pattern I see most: someone builds a custom select, puts role="option" on the items, but forgets to wrap them in a listbox container.

<!-- FAILS: options with no listbox parent -->
<div class="dropdown">
  <div role="option">Small</div>
  <div role="option">Medium</div>
  <div role="option">Large</div>
</div>

The container is a bare <div> with no role, so the option children have no owning listbox. Give them one. The parent must carry role="listbox" and the direct children must be the option nodes:

<!-- PASSES: listbox owns its options -->
<div class="dropdown" role="listbox" aria-label="Size">
  <div role="option" aria-selected="true">Small</div>
  <div role="option" aria-selected="false">Medium</div>
  <div role="option" aria-selected="false">Large</div>
</div>

If the DOM forces a wrapper element between the listbox and its option nodes, use aria-owns on the listbox to re-establish the relationship. But the clean fix is to make the parent a real listbox and keep the options as its direct children.

Required Parent for Each Context-Dependent Role

These are the child roles the check cares about and the parent each one must be contained by.

Child Role Must Be Contained By
option listbox
tab tablist
menuitem, menuitemradio, menuitemcheckbox menu or menubar
treeitem tree or group
listitem list
row rowgroup, table, grid, or treegrid
gridcell row

How to Detect It

  1. axe DevTools: the “Certain ARIA roles must be contained by particular parents” violation names each orphaned child and, in the failure summary, tells you which parent role it expected to find.
  2. Lighthouse: the Accessibility audit surfaces this under the ARIA group; expand it to see the exact nodes whose owning parent is missing.
  3. ARIA DevTools / accessibility tree: select the child in the Accessibility panel and walk up the tree. If the ancestor with the required container role isn’t there, that’s your break.

How to Fix It

  1. Read the violation to learn which parent role the child expects.
  2. Add that role to the direct parent element — e.g. role="listbox" on the container of your options.
  3. If a structural wrapper sits between them, either remove it or use aria-owns on the parent to reconnect the children.
  4. Give the parent an accessible name so the widget announces sensibly.
  5. Re-scan and confirm the tree now shows the child nested under the correct owner.

A word on where these bugs come from, because it’ll help you avoid the next one: they almost never start life as a missing parent. They start as a working widget that a later refactor split apart — someone extracts the option list into its own component and drops the listbox wrapper in the move, or a CSS-grid rewrite inserts row wrappers between the tablist and its tabs. The roles that were fine yesterday are suddenly orphans. So when this fires on code that used to pass, look at what recently reshaped the DOM around it rather than the roles themselves.

This is the mirror image of the sibling rule where certain ARIA roles must contain particular children — there the parent is missing its required kids. Fix both together when you touch a composite widget, and if you’re weighing how much of this hand-rolled ARIA is even worth it, the broader case for leaning on native semantics is laid out in accessibility and SEO.

FAQ

Can I Put Non-Option Elements Inside a Listbox?

Only option (and group wrapping options) are valid direct children of a listbox. Dropping a stray <button> or icon <div> in there will confuse the reader and can trip the companion “must contain particular children” rule.

Does aria-owns Really Fix a Broken Hierarchy?

Yes — aria-owns lets the parent claim children that aren’t its DOM descendants, rebuilding the accessibility tree relationship. Use it when layout constraints stop you from nesting cleanly, but prefer real DOM nesting when you can.

Why Does the Counting (“3 of 8”) Matter so Much?

Set-size and position announcements are how a non-visual user knows a menu has 8 items and they’re on the third. Orphan a child and the reader can’t compute the set, so those announcements disappear.

Is This the Same as Invalid ARIA Values?

No. This rule is about structural nesting. A misspelled or out-of-range attribute value is a different check — see ARIA attributes must conform to valid values.

If I Use Native Elements, Do I Still Have to Worry About This?

Much less. A real <ul><li>, a <select><option>, or a proper table already carry the correct parent-child roles in the accessibility tree, and browsers keep those relationships intact for you even when styling gets aggressive. The containment failures cluster almost entirely in hand-built widgets where developers assigned roles to generic <div>s and then reorganized the markup without re-checking the tree. When you have the choice, native structure is the cheapest insurance against this whole category of bug — you get the nesting guarantees for free instead of policing them by hand on every refactor.

Tìm lỗi này trên trang của bạn

Neova chạy mục kiểm tra này và mọi mục khác trong mỗi lần crawl, rồi viết cách sửa thành ticket cho nhóm của bạn.

  • Ứng dụng máy tính cho Mac, Windows và Linux
  • Tất cả 696 mục kiểm tra, mỗi mục kèm nguồn
  • Search Console và Analytics 4, kết nối chỉ đọc
  • Ticket sang Jira, Linear và Asana

Tải Neova Gói Desktop Free, hoặc dùng thử Solo miễn phí 14 ngày, không cần thẻ.

Tất cả mục kiểm tra Khả năng truy cập · Hướng dẫn · Thư viện mục kiểm tra

Do Neova Labs biên soạn · Quay lại Thư viện mục kiểm tra