If I'm using an <a>
tag click event to trigger an ajax call, and I don't want the link to physically go anywhere, what is the correct value for the href
attribute?
Is it '#' or just leave it empty?
(I understand the accessibility issues that this brings).
Definition and Usage. The href attribute specifies the URL of the page the link goes to. If the href attribute is not present, the <a> tag will not be a hyperlink. Tip: You can use href="#top" or href="#" to link to the top of the current page!
To answer your question: Yes it's valid. An <a> tag without a href represents something else, not a link (traditionally an anchor).
If the parser is unable to find a complete linkage for a sentence - one which links all the words together according to the requirements of the words - it begins to use "null-links". It begins by trying to parse the sentence, ignoring one word.
Better be #
because some browsers won't render <a>
with empty href
(for example Google chrome will render the anchor as a plain text).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With