Sometimes, we want to make an HTML link that does nothing.
In this article, we’ll look at how to make an HTML link that does nothing.
How to make an HTML link that does nothing?
To make an HTML link that does nothing, we set the href
and onclick
attributes.
For instance, we write
<a href="#" onclick="return false;"> nothing </a>
to add an a
element with the href attribute set to #
and onclick
attribute set toi return false
to stop navigation when clicking on it.
Conclusion
To make an HTML link that does nothing, we set the href
and onclick
attributes.