Starlit Daily

📚 › HTML: build the structure of a web page

9. Tabs and keyboard focus with tabindex

ستتم ترجمة هذا المقال تلقائيًا. يُعرض بالإنجليزية حاليًا.

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.

عرض المثال

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

✍️ دورك الآن

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

← العودة إلى الدورة