HTML
HTML 5

How To Disable A Anchor Tag In HTML?

This tutorial is focused on how to disable anchor tag in html using javascript. you will learn how to disable a tag in html. we will help you to give example of how to disable a element in javascript. This article goes in detailed on how to disable a tag in jquery. follow bellow step for how to disable a anchor tag in jquery.

  • 4.5/5.0
  • Last updated 08 September, 2022
  • By Admin

If you want to disable a tag then i will give you several examples of how to disable anchor tag using css, jquery and javascript.

So, let's see bellow some simple example that will help you how to disable a tag href in html.

Example 1:
<!DOCTYPE html>
<html>
<head>
    <title>How to Disable a Anchor Tag in HTML? - codewale.com</title>
    <style type="text/css">
        a.disabled {
          pointer-events: none;
          cursor: default;
          opacity: .6;
        }
    </style>
</head>
<body>
<h1>How to Disable a Anchor Tag in HTML? - codewale.com</h1>
  <a href="https://www.codewale.com" class="disabled">Go to codewale.com</a>
</body>
</html>
Example 2:
<!DOCTYPE html>
<html>
<head>
    <title>How to Disable a Anchor Tag in HTML? - codewale.com</title>
</head>
<body>
<h1>How to Disable a Anchor Tag in HTML? - codewale.com</h1>
<a href="https://www.codewale.com" onclick="return false;">Go to codewale.com</a>
</body>
</html>
Example 3:
<!DOCTYPE html>
<html>
<head>
    <title>How to Disable a Anchor Tag in HTML? - codewale.com</title>
</head>
<body>
<h1>How to Disable a Anchor Tag in HTML? - codewale.com</h1>
<a href="javascript:function() { return false; }">Go to codewale.com</a>
</body>
</html>
Example 4:
<!DOCTYPE html>
<html>
<head>
    <title>How to Disable a Anchor Tag in HTML? - codewale.com</title>
    <style type="text/css">
        a[disabled="disabled"] {
            pointer-events: none;
        }
    </style>
</head>
<body>
<h1>How to Disable a Anchor Tag in HTML? - codewale.com</h1>
<a href="https://www.codewale.com" disabled="disabled">Go to codewale.com</a>
</body>
</html>

I hope it can help you...