Categories
CSS

How to disable a link using only CSS?

Spread the love

Sometimes, we want to disable a link using only CSS.

in this article, we’ll look at how to disable a link using only CSS.

How to disable a link using only CSS?

To disable a link using only CSS, we set the pointer-events property.

For instance, we write

<a href="#" class="disabled">link</a>

to add a link.

Then we write

.disabled {
  pointer-events: none;
  cursor: default;
  opacity: 0.6;
}

to add pointer-events: none; to disable clicks on the link.

We set cursor: default; to set the cursor to the default arrow.

Conclusion

To disable a link using only CSS, we set the pointer-events property.

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 *