As you all know, it's extremely common to have code like this:
<a href='#' class='edit'>Edit</a>
Which is then hooked up to an event handler (using jQuery or whatever's hip these days)
or even with inline js handlers
<a href='#' onclick='editThis()'>Edit</a>
I know it's a lazy way to show the pointer/hand cursor on the link but that can easily be corrected with just this css:
a {
cursor:pointer;
}
(Which takes less time to write once in the stylesheet than writing href='#' on every link)
Having href='#'
also has the annoying inconvenience of causing the browser to jump to the top of the page if for some reason the handler hasn't had a chance to attach itself to the element (mouse trigger happy user, the impatient type, ...)
My question, is there a particular good reason to keep using the href='#'
?
Would removing it break some browser behaviour in a few particular contexts?
EDIT: I'm getting some really random answer for this question, maybe I should clarify.
The question is: if I set the hand cursor (and underline and color - thanks Borealid) via css, can I get rid of the href attribute altogether
This question is NOT about what the best href is or how one should attach event handlers