HTML & CSS · Middle · Question 39 of 75
What does tabindex="-1" do?
- 1Makes the element first in the Tab order, before all others
- ✓Correct answer: Allows focus only programmatically (
el.focus()), not via Tab - 3Completely forbids focusing the element - via Tab and from JavaScript
Explanation
tabindex="0" adds an element to the natural tab order, while -1 makes it focusable only via JS (e.g. a modal heading or a container when following an anchor). Positive values change the tab order and are considered an anti-pattern. To remove an element from interaction entirely, use the inert attribute.