I am parsing a HTML file and I noticed that there is one element that reads:
<a id="someID" class="someClass" href="#" style="someStyle">
Can I please ask what this href="#"
lead to?
I am parsing a HTML file and I noticed that there is one element that reads:
<a id="someID" class="someClass" href="#" style="someStyle">
Can I please ask what this href="#"
lead to?
It doesn't go anywhere. This is a common placeholder for links that are implemented using Javascript. Another popular style is href="javascript:void(0)"
; void()
is a function that does nothing. Finally, the Javascript function that's run when you click on it could use event.preventDefault()
to prevent the normal action of following the link. But you should still put a placeholder in the href
, so that when the user hovers over the link it won't show a target in the browser's status line.
I generally use '#' to a trigger a JavaScript which works with CSS or page layout. In whole, its just a way to make a dead-link(not leading to any page) which you can use to call various webpage activites like JS or CSS.