a href="javascript: void(0)"
is considered a bad practice and I can't use href="#"
in every case, so I'm thinking to add an empty a
with tabIndex=0
in order to be accessible with keyboard.
Is it considered a good practice?
P.S. Bootstrap's dropdown needs <a>
in inner elements for keyboard navigation, so I have to use <a>
.
<button type="button">...</button>
instead of a link? – Meyerbeertabindex="0"
, it must support the relevant keyboard interaction (e.g., it should respond toEnter
orSpace
). By default, at least in Chrome and Firefox,a
elements with nohref
but withtabindex="0"
do not (not even withrole="link"
orrole="button"
). So if you do this, ensure that those work (Bootstrap may already do so). I would also suggest that if you do this, you add the appropriaterole
value. – Stampede<a>
because that's the way Bootstrap dropdown has implemented keyboard navigation in dropdowns. – Eurydicehref="#"
is not a good practice either. You should put a link to the site that would take you to the actual target of the navigation entry. – Chalcidice