Performance: Keyboard navigation basics
This affects user interaction responsiveness and accessibility, impacting how quickly users can navigate and interact with page elements using the keyboard.
<button onclick="doSomething()">Click me</button>
<div onclick="doSomething()">Click me</div>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Non-semantic clickable div without keyboard support | Low | 0 | Low | [X] Bad |
| Semantic button element with native keyboard support | Low | 0 | Low | [OK] Good |
| Using tabindex="-1" to remove focusable elements | Low | 0 | Low | [X] Bad |
| Natural DOM order with no tabindex manipulation | Low | 0 | Low | [OK] Good |
tabindex attribute sets the order in which elements receive keyboard focus.onclick is for mouse clicks, alt is for images, href is for links.<button>Save</button> <div tabindex="0">Info</div> <a href="#">Link</a>
<div tabindex="-1">Menu</div>
Pass the test and this pattern moves unknown