In this tutorial we will see how to Disable HTML Link using CSS. CSS pointer-events property and CSS opacity property are used to disable the link completely.
Table of Contents
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
Video Tutorial
Watch video tutorial on Disable HTML Link using CSS.