QUESTIONS

Disabled href tag on Html using css or javascript?

  Alan Coromano       2021/09/06       91


91

The question and answer about this post on Disabled href tag on Html using css or javascript? have a total of 8 answer so far..

asked
8 answers
91 votes

SOLUTIONS: (8)

0
      13

Although that link is disabled, it's still clickable.

<a href="/" disabled="disabled">123n</a>

Can I make it not-clickable if it's disabled? Should I use JavaScript necessarily?

0
      8

There is no disabled attribute for hyperlinks. If you don't want something to be linked then you'll need to remove the <a> tag altogether.

Alternatively you can remove its hrefattribute - though this has other UX and Accessibility issues as noted in the comments below so is not recommended.

0
      9

With the help of css you will disable the hyperlink. Try the below

 

a.disabled {
  pointer-events: none;
  cursor: default;
}
<a href="link.html" class="disabled">Link</a>
0
      8

The <a> tag doesn't have a disabledattribute, that's just for <input>s (and <select>s and <textarea>s).

To "disable" a link, you can remove its hrefattribute, or add a click handler that returns false.

0
      8

HTML:

<a href="/" class="btn-disabled" disabled="disabled">123n</a>

CSS:

.btn-disabled,
.btn-disabled[disabled] {
  opacity: .4;
  cursor: default !important;
  pointer-events: none;
}
0
      8

CSS only: this removes the link from the href.

.disable { 
    pointer-events: none; 
    cursor: default; 
}

 

0
      8

Letting a parent have pointer-events: nonewill disable the child a-tag like this (requires that the div covers the a and hasn't 0 width/height):

<div class="disabled">
   <a href="/"></a>
</div>

where:

.disabled {
    pointer-events: none;
}
0
      8

You can emulate the disabled attribute on a <a> tag.

<a href="link.html" disabled="">Link</a>

a[disabled] {
   pointer-events: none;
   cursor: default;
}

QUESTIONS:


Nfiles Questions - nfiles.xyz the Q nad A blogs sites for free
🗂 Nfiles » Home
🗂 ModStore
🗂 Videos
🗂 Shareurl
🗂 About us
🗂 Bitcoin

Connecting...
👤 Mr. snow finger
👤 Yoki No moto
👤 Xdeveloper
👤 Malitanyo Dev
👤 Money Motto
👤 Ako Johnny Sin
Create with ❤ Questions by nfiles.xyz 2021