Is there any way to disable a link using CSS?
I have a class called current-page
and want links with this class to be disabled so that no action occurs when they are clicked.
Is there any way to disable a link using CSS?
I have a class called current-page
and want links with this class to be disabled so that no action occurs when they are clicked.
You can set
href
attribute tojavascript:void(0)
Demo here
Try this one
CSS can only be used to change the style of something. The best you could probably do with pure CSS is to hide the link altogether.
What you really need is some javascript. Here's how you'd do what you want using the jQuery library.
If you want to stick to just HTML/CSS on a form, another option is to use a button. Style it and set the
disabled
attribute.E.g. http://jsfiddle.net/cFTxH/1/
That's not the only way you disable a Link, but a good CSS way which work in IE10+ and all new browsers:
pointer-events:none
will disable the link: