tabindex not working same in chrome and firefox
Solutions for your problem is to add negative tab index (tabindex="-1"
) to links inside your <li>
.
For more details on tabindex
you may read this.
https://developers.google.com/web/fundamentals/accessibility/focus/using-tabindex
* {
margin: 0;
padding: 0;
}
.menu ul {
list-style: none;
}
.menu ul > li {
display: inline-block;
position: relative;
}
.menu ul > li a {
display: block;
padding: 5px 10px;
}
.menu ul > li > ul {
position: absolute;
display: none;
}
.menu ul > li.open > ul,
.menu ul > li:hover > ul {
display: block;
}
<div class="menu">
<ul>
<li tabindex="0"><a tabindex="-1" href="#">Link 1</a></li>
<li tabindex="0" ><span>dropdown 1</span>
<ul>
<li><a href="#">Link 1</a></li>
<li><a href="#">Link 2</a></li>
<li><a href="#">Link 3</a></li>
<li><a href="#">Link 4</a></li>
</ul>
</li>
<li tabindex="0"><a tabindex="-1" href="#">Link 2</a></li>
<li tabindex="0"><a href="#">Link dropdown</a>
<ul>
<li><a href="#">Link 1</a></li>
<li><a href="#">Link 2</a></li>
<li><a href="#">Link 3</a></li>
<li><a href="#">Link 4</a></li>
<li><a href="#">Link 4</a></li>
</ul>
</li>
</ul>
</div>
How to allow keyboard focus of links in Firefox?
Ok, somebody explained this to me. It's a Mac problem. Mozilla is being true to operating system settings in Mac OS.
There are two distinct ways around this on the user side. Both seem to work:
In System Preferences → Keyboard, in the Shortcuts pane, check the “all controls” radio at the bottom.
In Firefox, type "
about:config
" in the URL bar. There is noaccessibility.tabfocus
preference on the mac, so you'll have to make one. Right click in the window, create a new "integer" pref, and set it to 7.
Neither of these are terribly obvious. Also, neither of these are a server-side solution for developers, which is frustrating.
Cannot get keyboard focused for a link elements in SVG under Firefox
Tabindex and focus/blur support for SVG has just been implemented in Firefox and will appear in version 51.
You can see it in a Nightly right now if you want.
Related Topics
Set Margin/Padding for Each Page to Print (Html/Css)
Why Won't Tabindex Work with Firefox
Display: Flex - Not Working in Firefox 21
Equal Width Using Flex and Border-Box
How to Position Child Div to the Center of Every Parents Div Using Position Absolute in CSS
Make Two Parallel '<Div>' Colums the Same Height
How to Make a 2 Column Layout Where Items Starts from Top to Bottom (Not Left to Right)
Aligning Two Flex Items: One to the Top, the Other Centered
How to Apply CSS Stylesheet to Single Specific Element
Webkit Opacity Transition Issues with Text
My Nested <Li> Is Inheriting the Styles from Its Parent
To Use Local Font in HTML Using Font Face
Why Does Vertical-Align: Text-Top Make Element Go Down
Setting Overflow: Scroll on a Table with Display: Flex
Scope External CSS File for Div(No CSS File Should Link Only )