To create an Inactive URL use javascript void(0) in href. You have to combine the pseudo URL (javascript:) with void(0) as a value of an href, it tells the browser to return/do nothing when that link is clicked.
javascript void(0) in href
For a simple example code, 0 is passed to void as an argument, it does nothing or returns nothing.
<!DOCTYPE html>
<html lang="en">
<body>
<pre>
Syntax to make Inactive Javascript URLs:
<a href="javascript:void(0)">Click here to do nothing.</a>
</pre>
<p>Example</p>
<a href="javascript:void(0)">Inactive URL</a>
</body>
</html>
Output:
We are defining two links that have alert boxes. In one link, we are using the void keyword. The void() operator will return an undefined value. Hence the alert function will not display on the page.
<!DOCTYPE html>
<html lang="en">
<body>
<a href = "javascript:void(javascript:alert('hello world!!'))">
It will do nothing.
</a>
<br/><br/>
<a href = "javascript:alert('Hello');">Click here for an alert</a>
</body>
</html>
Do comment if you have any doubts or suggestions on this Js void topic.
Note: The All JS Examples codes are tested on the Firefox browser and the Chrome browser.
OS: Windows 10
Code: HTML 5 Version