5

I want to disable a tag if it's already set -- e.g., disable a menu using disabled = "true" or something.

I can remove a tag completely using PHP; but I have already styled it and only want to disable it. Is it possible?

Yatharth Agarwal
  • 4,385
  • 2
  • 24
  • 53
Simon
  • 22,637
  • 36
  • 92
  • 121

3 Answers3

7

Nope, there is no CSS-only way known to me to disable a link the way you describe.

The only thing that comes to mind is putting an additional, transparent element in front of the link, but that can't be achieved in pure CSS, either.

How about giving it a href='#' onclick='return false' when generating them in PHP?

Pekka
  • 442,112
  • 142
  • 972
  • 1,088
  • @Pekka it is something what i want. thanks much. i even don't need href='#', that's enough onclick='return false';) – Simon Mar 28 '10 at 15:42
  • 1
    @Syom you're welcome. You should use `href='#'` as well, though, for users who have JavaScript disabled. – Pekka Mar 28 '10 at 15:44
  • 1
    you can use `pointer-events: none;` to disable the link and use more css to make it look disabled – Elena Dec 08 '15 at 11:57
  • @Pekka review the last post.. you will find CSS does work. – roblem Sep 14 '22 at 14:02
1

you could also use the css property display:none;

Gabriel
  • 1,820
  • 2
  • 23
  • 31
1

you can try this

a.disabled_class_name{
    pointer-events: none;
    cursor: default;
}
Durgpal Singh
  • 11,481
  • 4
  • 37
  • 49
Denish Vachhani
  • 146
  • 1
  • 10