How7o
  • Home
  • Tools
  • Prank Screens
  • Learn
  • Blog
  • Contact
Reading: How to Skip a Link When Pressing Tab (tabindex=-1)
Share
How7oHow7o
Font ResizerAa
  • OS
Search
  • Home
  • Tools
  • Prank Screens
  • Learn
  • Blog
  • Contact
Follow US
© 2024–2026 How7o. All rights reserved.
How7o > Free Laravel, PHP, WordPress & Server Tutorials > Web Development > How to Skip a Link When Pressing Tab (tabindex=-1)
Web Development

How to Skip a Link When Pressing Tab (tabindex=-1)

how7o
By how7o
Last updated: May 22, 2026
5 Min Read
Prevent tab key from focusing on a link with tabindex=-1
SHARE

To prevent the Tab key from focusing on a specific <a> tag, add tabindex="-1" to it. The negative value removes the element from the natural keyboard tab order — it stays clickable with the mouse, but pressing Tab skips over it.

Contents
  • The one-attribute fix
  • How tabindex values behave
  • The better fix — reorder the markup
  • Accessibility note
  • Frequently asked questions
  • Related guides
  • References

Last verified: 2026-05-17 in Chrome 124, Firefox 125, Safari 17. Originally published 2023-01-21, rewritten and updated 2026-05-17.

The one-attribute fix

<a href="#" id="forgot-password" tabindex="-1">Forgot Password</a>

With tabindex="-1", the user’s Tab key jumps straight from the username field to the password field, skipping the “Forgot Password” link.

Skip a link with Tab — tabindex=-1, DOM reorder alternative, accessibility note

How tabindex values behave

  • tabindex="0" — included in the natural tab order at its DOM position. Used to make non-interactive elements focusable (e.g. <div tabindex="0">).
  • tabindex="-1" — not in the tab order, but still programmatically focusable via .focus(). The case we want here.
  • tabindex="1" and above — forces a custom tab order regardless of DOM. Almost always a bug magnet; let DOM order dictate tab order instead.
  • No tabindex at all — interactive elements (<a href>, <button>, form fields) are tabbable by default; non-interactive ones aren’t.

The better fix — reorder the markup

<form>
  <label for="username">Username</label>
  <input type="text" id="username" name="username">

  <label for="password">Password</label>
  <input type="password" id="password" name="password">

  <a href="#" id="forgot-password">Forgot Password</a>

  <button type="submit">Log In</button>
</form>

Move “Forgot password” below the password input (visually and in the DOM). Tab order follows DOM order — username → password → forgot password → log in is the natural flow most users expect, and no tabindex tricks are needed.

Accessibility note

tabindex="-1" removes the element from keyboard tab navigation, not from accessibility. Screen-reader users in virtual-cursor mode can still reach the link with arrow-key navigation; mouse users can still click it. The element is still announced and reachable — it just doesn’t interrupt the form-filling tab path.

Frequently asked questions

Does tabindex="-1" hide the element from screen readers?

No — it only removes the element from the keyboard tab order. Screen-reader users navigating with virtual-cursor mode (arrow keys) can still encounter it. tabindex="-1" excludes from keyboard tabbing, not from accessibility — which is exactly what you want for a “Forgot password” link that should be reachable but not on the password-entry path.

Is this an accessibility regression?

It can be if you remove keyboard access to everything. For an inline link inside a form, skipping it during tab and reaching it on mouse or via Shift+Tab from later focus points is reasonable. Audit yourself by trying to complete the form with only the keyboard — if the user can still reach “Forgot password” (e.g. after reaching the submit button, Shift+Tab back), the change is fine.

Why is the link before the password field at all? Wouldn’t it be simpler to move it?

Yes, when you control the layout — move “Forgot password” below the password input or to the right of it. tabindex="-1" is the right tool when the DOM order is dictated by a template you can’t change (theme, plugin, third-party widget). When you can edit the markup, fixing the visual + DOM order is the more robust fix.

What’s the difference between tabindex="-1" and tabindex="0"?

0 includes the element in the natural tab order at its position in the source. -1 excludes it from tab order entirely but makes it programmatically focusable (you can call .focus() on it). Positive values like tabindex="5" force a custom order — almost always a mistake; let DOM order dictate tab order.

Related guides

  • How to Add a Required Attribute to Input Fields in jQuery
  • How to Disable or Enable an Input with JavaScript or jQuery
  • How to Auto-Focus a Select2 Dropdown on Page Load

References

MDN tabindex: developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex. WAI-ARIA Authoring Practices on keyboard interaction: w3.org/WAI/ARIA/apg/practices/keyboard-interface.

TAGGED:accessibilityformshtml

Sign Up For Daily Newsletter

Be keep up! Get the latest breaking news delivered straight to your inbox.
[mc4wp_form]
By signing up, you agree to our Terms of Use and acknowledge the data practices in our Privacy Policy. You may unsubscribe at any time.
Share This Article
Facebook Copy Link Print
Previous Article Open a file selection dialog from a button click How to Open a File Dialog When Clicking a Button
Next Article Nginx redirect www to non-www or vice versa How to Redirect www to non-www (or vice versa) in Nginx
Leave a Comment

Leave a Reply Cancel reply

You must be logged in to post a comment.

FacebookLike
XFollow
PinterestPin
InstagramFollow
Most Popular
Run Laravel queue workers with Supervisor
How to Run Laravel Queue Workers in Production with Supervisor
May 23, 2026
Nginx as a reverse proxy for a Node.js app on Ubuntu
How to Set Up Nginx as a Reverse Proxy for Node.js on Ubuntu
May 23, 2026
Install and configure Redis on Ubuntu for Laravel and WordPress
How to Install and Configure Redis on Ubuntu (for Laravel & WordPress)
May 23, 2026
Harden a fresh Ubuntu VPS with UFW, Fail2Ban, and SSH key auth
How to Harden a Fresh Ubuntu VPS: UFW + Fail2Ban + SSH Key Auth
May 23, 2026
Set up Let's Encrypt SSL with Certbot on Ubuntu
How to Set Up Let’s Encrypt SSL with Certbot on Ubuntu (Apache & Nginx)
May 23, 2026

You Might Also Like

Fix MySQL CONCAT returning NULL with COALESCE or CONCAT_WS
Web Development

How to Handle MySQL CONCAT Returning NULL

4 Min Read
Check if GD library is installed in PHP (phpinfo and extension_loaded)
Web Development

How to Check if GD Library Is Installed in PHP (3 Easy Methods)

5 Min Read
Replace Broken Images Automatically with JavaScript
Web Development

Replace Broken Images Automatically with JavaScript (and jQuery)

5 Min Read
Laravel MySQL variable in select — @name := assignment chains values across select items
Web Development

How to Set a MySQL Variable in Laravel Query Builder Select

8 Min Read
How7o

We provide tips, tricks, and advice for improving websites and doing better search.

Tools

  • Age Calculator
  • Word Counter
  • Image Upscaler
  • Password Generator
  • QR Code Generator
  • See all tools→

Pranks

  • Fake Blue Screen Prank
  • Hacker Typer
  • Fake iMessage Generator
  • Windows XP Crash Prank
  • Windows 11 Update Prank
  • See all prank screens →

Company

  • About Us
  • Blog
  • Contact
  • Privacy Policy
  • Terms of Service
  • Sitemap
© 2024–2026 How7o. All rights reserved.
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?