JavaScript Answers

How to make an HTML link that does nothing?

Spread the love

To create an HTML link that does nothing when clicked, you can use the href attribute with a value of javascript:void(0);.

This will effectively create a link that, when clicked, executes a JavaScript function that does nothing.

For example we write:

<a href="javascript:void(0);">Click here</a>

This link will appear as clickable text (“Click here”), but clicking on it will not cause any navigation or action to occur.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *