Khalil Ghâñmî

0 %
Khalil Ghâñmî
Développeur full-stack
  • Residence:
    Tunis
  • City:
    Bardo
  • Age:
    30
French
English
arabe
  • HTML 5 / CSS 3
  • Bootstrap
  • JavaScript / Jquery/Ajax
  • ReactJS
  • API
  • Angular
  • PHP/Mysql
  • Python
  • Java
  • Wordpress
  • OpenCart
  • Illustrator | Photoshop | Premier Pro | Animate
  • OVH | Godaddy | Vipdomaine | Zenhosting | LWS | Hostgator
  • Cpanel
  • Google Search | Google sheets | Google docs | Office

How to Disable a Link using Only CSS

23 August 2022

Answer: Use the CSS pointer-events Property

You can simply use the CSS pointer-events property to disable a link. The none value of this property specify the element is never the target of pointer events.

Let’s try out the following example to understand how it actually works:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Disable an HTML Link using CSS</title>
<style>
    .disabled-link{
        cursor: default;
        pointer-events: none;        
        text-decoration: none;
        color: grey;
    }
</style>
</head>
<body>
    <a href="somepage.html" class="disabled-link">HTML Link</a>
</body>
</html>

The pointer-events property supported in all major browsers, such as Chrome, Firefox, Safari, IE11+, etc. Alternatively, you can use jQuery to remove the clickable behavior from a disabled link.

Posted in css, Non classé, WebTags:
Write a comment