Prevent tabstop on A element (anchor link) in HTML

HtmlAnchorTabstop

Html Problem Overview


Is it possible to cancel an <a href="..."> from being tabstopped in any browser? I would like to do this without Javascript.

Html Solutions


Solution 1 - Html

Some browsers support the tabindex="-1" attribute, but not all of them, since this is not a standard behaviour.

Solution 2 - Html

Modern, HTML5 compliant, browsers support the [tabindex] attribute, where a value of -1 will prevent the element from being tabbed to.

> If the value is a negative integer
> The user agent must allow the element to be focused, but should not allow the element to be reached using sequential focus navigation.

Solution 3 - Html

You could apply a JQuery handler to the element you want to target multiple elements with no tab stop.

$(document).ready(function () {
    $('.class').attr('tabindex', '-1');
});

Would be one way to do it....

Solution 4 - Html

I think you could do this by javascript, you override the window.onkeypress or onkeydown, trap the tab button, and set the focus at the desired order.

Solution 5 - Html

Remove the href attribute from your anchor tag

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRobert KoritnikView Question on Stackoverflow
Solution 1 - HtmlRoberto AloiView Answer on Stackoverflow
Solution 2 - HtmlzzzzBovView Answer on Stackoverflow
Solution 3 - HtmldtharpeView Answer on Stackoverflow
Solution 4 - HtmlAmmosiView Answer on Stackoverflow
Solution 5 - HtmlCodeDreamer68View Answer on Stackoverflow