How to disable an anchor tag in HTML

Sometimes we may need to disable an anchor tag in HTML. There are so many ways to disable the a tag but in this article we will explain to you the three different methods with examples to disable the anchor tag.

Three different ways to disable an anchor tag

  1. Using CSS
  2. Using Inline JavaScript
  3. Using click event

1. Using CSS

The pointer-events: none CSS style can be used to deactivate an HTML anchor element.

All click events on the anchor element will be disabled if pointer-events: none is set.

2. Using Inline JavaScript

Disable HTML anchor with inline JavaScript href="javascript:void(0)".

3. Using click event

Let’s bind the click event to a tag.

I hope you find this article helpful.
Thank you for reading. Happy Coding..!! 🙂

If you found value in this article,
you can support us by buying me a coffee! ☕

You may also like...

Leave a Reply

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