login
I\'ve seen such href
s many times, but I don\'t know what exactly
It is a very popular method of adding JavaScript functions to HTML links.
For example: the [Print]
links that you see on many webpages are written like this:
Print
Why do we need href
while onclick
alone can get the job done? Because when users hover over the text 'Print' when there's no href
, the cursor will change to a caret (ꕯ) instead of a pointer (👆). Only having href
on an a
tag validates it as a hyperlink.
An alternative to href="javascript:void(0);"
, is the use of href="#"
. This alternative doesn't require JavaScript to be turned on in the user's browser, so it is more compatible.