
Why are you even asking about a thing that is somehow not supposed to look like a button, as opposed to not supposed to behave like a button?
The preceding conversation context would explain that. I initially mentioned that javascript:void(0) specifically is useful in a way that the javascript: protocol as a whole is not, and was asked for use cases, and one of the two I replied with was that if something is supposed to not look like a button then <a href="javascript:void(0)"> is a simpler starting point than (roughly) <button type="button" form="" style="appearance: none; display: inline"> – but the answer I got was that buttons should look like buttons and links should look like links, a statement whose connection to what I said I don’t understand. So I asked for clarification about how it relates back to the preceding conversation – which conversation was precisely about such “a thing that is somehow not supposed to look like a button, as opposed to not supposed to behave like a button”.
I think if things are so bad, just using
href="#"would not really stand out of the mess.
That scrolls to the top of the page and also changes the location in the address bar (at the least). Particularly for the “I actually don’t have a link to output here nor any mechanism to signal that” case that would be a very bad replacement. For the “links don’t require fighting as many defaults” case it can be dealt with using preventDefault, which indeed is no big deal though nevertheless marginally less robust.
Now, for bookmarklets
javascript:is still useful — butfile:///URLs work in bookmarks but not when inserted into HTML, so maybe we can separate the two cases?
There was discussion about that in some other subthread.
score 1 · canonical
score 1 · canonical