Starlit Daily

📚 › HTML: build the structure of a web page

9. Tabs and keyboard focus with tabindex

Este artículo se traducirá automáticamente. Por ahora se muestra en inglés.

When a visitor presses the Tab key, the browser moves focus between links, buttons and form fields in page order. Focus is shown with an outline, so people using a keyboard can see where they are.

tabindex="0" makes any element reachable with Tab. tabindex="-1" keeps it out of the Tab order but still lets scripts focus it. Avoid positive numbers; they break the natural order.

Ver ejemplo

<a href="/home">Home</a>
<div tabindex="0">Focusable box</div>

✍️ Ahora te toca

Make a div with the text Click me that can be reached with the Tab key.

← Volver al curso