The Tabs Pattern: tablist, tab, tabpanel
Wire the three roles a tab set needs.
The Tabs Pattern: tablist, tab, tabpanel is a free Web Accessibility Academy lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Web Accessibility Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
What a Tab Set Really Is
A tab set shows one panel at a time and lets users switch between them. To assistive tech it must look like one widget, not loose links.
Three Roles Work Together
The pattern relies on three ARIA roles: a tablist that holds the tabs, each tab, and the panel each tab reveals. Get all three right.
The Container Is a tablist
Wrap your row of tabs in an element with role="tablist". This tells screen readers the children inside are a related set of tabs.
<div role="tablist">...</div>Each Tab Is a Button
Build each tab from a real button with role="tab". A button is focusable and clickable for free, so you avoid extra wiring.
<button role="tab">Profile</button>The Panel Is a tabpanel
The content each tab shows gets role="tabpanel". This marks it as the region controlled by the currently selected tab.
<div role="tabpanel">Profile details</div>Mark the Selected Tab
Set aria-selected="true" on the active tab and false on the rest. Screen readers announce which tab is currently chosen.
<button role="tab" aria-selected="true">Profile</button>Link Tab to Its Panel
Point each tab at its panel with aria-controls, set to the panel id. Users learn which region the tab opens.
<button role="tab" aria-controls="p1">Profile</button>Name the Panel From Its Tab
Give the panel an aria-labelledby that points back to its tab. Now the panel borrows the tab text as its accessible name.
<div role="tabpanel" aria-labelledby="tab1">...</div>Hide the Inactive Panels
Only one panel should show at a time. Add the hidden attribute to the panels whose tab is not selected so they leave the page.
<div role="tabpanel" hidden>...</div>Give the Tablist a Label
A tablist deserves an aria-label describing its purpose, like Account settings. Users hear what the whole set of tabs is for.
<div role="tablist" aria-label="Account settings">...</div>How It All Sounds
Put together, a screen reader announces something like Profile, tab, selected, 1 of 3. That orientation is exactly what makes tabs usable.
Quick Check
You are wiring up the container that holds your row of tabs. Which role belongs on it?
Recap: The Tabs Pattern
You learned the tablist, tab, tabpanel trio. Mark the selected tab, link each tab to its panel, and hide the inactive ones.
Frequently asked questions
Is the “The Tabs Pattern: tablist, tab, tabpanel” lesson free?
Yes — the full text of “The Tabs Pattern: tablist, tab, tabpanel” is free to read here on the web, and the Web Accessibility Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Web Accessibility Academy course, upgrade to CoddyKit PRO.
What will I learn in “The Tabs Pattern: tablist, tab, tabpanel”?
Wire the three roles a tab set needs. You practise Web Accessibility Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Web Accessibility Academy?
No prior experience is required. Web Accessibility Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “The Tabs Pattern: tablist, tab, tabpanel” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Web Accessibility Academy lesson?
Yes. Every Web Accessibility Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- The Tabs Pattern: tablist, tab, tabpanel
- Arrow-Key Navigation Between Tabs
- Accordions With Button and aria-expanded
- Disclosure vs Tabs: Pick the Right One