It’s not at all uncommon to need to create an anchor element but not have it actually link to specific location.
With event-driven websites and the ubiquitous nature of Ajax, we’re often setting up anchors to trigger displays or other behavior.
At one point in time, the default “empty href” for an anchor was the use the pound (or hash) symbol:
[cc lang=”html”]
Click Here!
[/cc]
Unfortunately, this has some unintended side effects in modern browsers. Specifically, the browser treats this as an in-page bookmark and will usually take the user back to the top of the page.
To prevent this, simply specify the default location as:
[cc lang=”html”]
Click Here!
[/cc]
Some purists will argue that this assumes that users have JavaScript enabled. There’s some truth to this, but the majority of websites now require that you actually have JavaScript-enabled to use their site.
Your call, but I favor – and always use – the latter.
Speak your mind...