0Pricing
Web Accessibility Academy · Lesson

tabindex 0, -1, and Never Positive

Control what is focusable and what is only scriptable.

tabindex 0, -1, and Never Positive is a free Web Accessibility Academy lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Web Accessibility Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

What tabindex Controls

The tabindex attribute decides whether an element can receive keyboard focus and how it fits into the Tab order. It is your dial for focusability.

Most Things Are Already Focusable

Links, buttons, and inputs are focusable by default, so you rarely touch tabindex on them. Reach for it only when the native element cannot do the job.

tabindex 0 Joins the Order

Setting tabindex="0" puts a normally non-focusable element into the natural Tab order, right where it sits in the DOM.

<div role="button" tabindex="0">Custom action</div>

When to Use 0

Use tabindex="0" on a custom widget you built from a div or span that must be reachable by keyboard, like a scripted toggle.

tabindex -1 Means Scriptable Only

With tabindex="-1", an element is skipped by the Tab key but can still be focused from JavaScript using element.focus().

<div id="panel" tabindex="-1">Result area</div>

Why -1 Is So Useful

You use tabindex="-1" to move focus to a region after an action, like a results panel, without adding it to every Tab press. 🎯

Never Use Positive Values

A positive tabindex like 3 jumps that element ahead of everything, scrambling the order and trapping you in a maze. Avoid it.

<input tabindex="3">

Positive Values Break the Flow

Any element with a positive value is visited before all the tabindex="0" and default elements, so the focus order stops matching the visual order.

Let the DOM Set the Order

The cleanest Tab order comes from DOM order itself. Arrange your markup logically and most focus problems disappear on their own.

Do Not Make Everything Focusable

Adding tabindex="0" to plain text or whole containers creates noise, forcing keyboard users to Tab through stops that do nothing.

A Simple Rule of Thumb

Use 0 to add a custom control to the order, -1 to focus by script only, and never a positive number. That covers almost everything.

Quick Check

Which tabindex value makes an element focusable by script but skips it in the Tab order?

Recap

You now own the tabindex dial: 0 adds custom controls to the order, -1 enables scripted focus, and positive values are off-limits. 👍

Frequently asked questions

Is the “tabindex 0, -1, and Never Positive” lesson free?

Yes — the full text of “tabindex 0, -1, and Never Positive” is free to read here on the web, and the Web Accessibility Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Web Accessibility Academy course, upgrade to CoddyKit PRO.

What will I learn in “tabindex 0, -1, and Never Positive”?

Control what is focusable and what is only scriptable. You practise Web Accessibility Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Web Accessibility Academy?

No prior experience is required. Web Accessibility Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “tabindex 0, -1, and Never Positive” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Web Accessibility Academy lesson?

Yes. Every Web Accessibility Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. tabindex 0, -1, and Never Positive
  2. Moving Focus After an Action
  3. Returning Focus When a Layer Closes
  4. Managing roving tabindex in Widgets
← Back to Web Accessibility Academy