Disable HTML Link using CSS

In this tutorial we will see how to Disable HTML Link using CSS. CSS pointer-events property and CSS opacity property is used to disable the link completely.

HTML Code

Simple HTML Code is given below, In this code we have HTML link element inside the main body of html document.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Disable HTML Link using CSS</title>  
</head> 
<body>

<a href="https://www.howtocodeschool.com/">HowToCodeSchool.com</a>
    
</body>
</html>

CSS pointer-events Property

CSS pointer-events property defines whether or not an element should react to the mouse cursor or pointer events. You can also specify how an element should react on pointer event.

The CSS pointer-events Property can have four possible values assigned to it, auto, none, initial and inherit.

CSS pointer-events Property is supported by all major browsers.

CSS Code

CSS code is given below, in this code we have just used pointer-events property to disable our main link and we also changed it's opacity to 50%, so that it also looks disabled.

a {
  text-decoration: none;
  pointer-events: none;
  opacity: 0.5;
}

Demo is shown in the video tutorial given below.

Video Tutorial

Watch video tutorial on Disable HTML Link using CSS.