tabindex and accesskey
Control keyboard navigation order and shortcuts.
Keyboard Navigation
Users without mice rely on Tab to navigate interactive elements:
- Naturally focusable:
<a href>,<button>,<input>,<select>,<textarea> - Non-interactive elements (
<div>,<span>) are not in the tab order tabindexcontrols whether and where an element appears in the tab order
tabindex="0"
tabindex="0" adds a non-interactive element to the natural tab order:
<div tabindex="0" role="button" onclick="handleClick()">
Custom Button
</div>
<!-- Now Tab navigates to this div -->
<!-- It receives focus at the natural position in the DOM -->
<!-- Better: use a real button instead! -->
<button onclick="handleClick()">Real Button</button>All lessons in this course
- id class style and title
- The hidden Attribute
- tabindex and accesskey
- Custom Data Attributes data-*