href must not reload

I think javascript:; also works.

<a href="javascript:;">Link</a>

Just add javascript:void(0) in href you will get..

<a href="javascript:void(0)">Link</a>

If you don't want it to behave like a link, then don't use a link tag. Doing so hurt accessibility of a page, and you don't want that. There are other ways of browsing a website than a browser (think about the screen readers), which relies on the semantics of the page elements. Use a span if you simply want to apply a style.

If you still want to use an anchor, you can use this -

<a href="#" onclick="return false;">Link</a>

This will prevent your page reloading.


Simply don't specify href attribute:

<a>Link</a>

A link without href...

  • does not reload a page on click
  • does not change cursor to pointer on hover
  • does not change text style to underlined

Tags:

Html

Hyperlink