Tabs in HTML is not easy
Link: How Tabs Should Work
REQUIREMENTS: WHAT MAKES THE PERFECT TAB?
- All content is navigable and available without JavaScript (crawler-compatible and low JS-compatible).
- ARIA roles.
- The tabs are anchor links that:
- are clickable
- have block layout
- have their
href
pointing to theid
of the panel element- use the correct cursor (i.e.
cursor: pointer
).- Since tabs are clickable, the user can open in a new tab/window and the page correctly loads with the correct tab open.
- Right-clicking (and Shift-clicking) doesn’t cause the tab to be selected.
- Native browser Back/Forward button correctly changes the state of the selected tab (think about it working exactly as if there were no JavaScript in place).
I created the following example of adding ARIA-roles to tabs. But Remy’s example is obviously more complete.
Published on 2015-12-25 by Makzan.
More articles like this:
-
Accessibility
-
Clip & Quote
-
JavaScript
-
Web Technologies
Previous ← Link: Regular Expression Crossword Puzzle
Next → Link: Japanese bookshop stocks only one book at a time