CSS
HTML
JavaScript
jQuery
PHP
SQL
WordPress
CSS Snippets

Code Snippet

There may come a time when you have an HTML text link that needs to be temporarily disable for some reason (perhaps it’s auto-created by a CMS, but the page is not yet finished).

In the following, we have an auto-generated link, but we want to remove the link temporarily because the source is not yet ready for viewing.

				
					<a class="sidebar_link" href="mylink.html">My Link</a>
				
			

In this case, we have a class attached to the element. Referencing the class, we can use the pointer-events property set to none, which will keep the link from responding to cursor or touch events. Now the link won’t work.

				
					.sidebar_link {
    pointer-events: none;
    text-decoration: line-through;
}
				
			

If you really want to keep things neat and tidy, you may want to have a CSS style setup just for disabling links (if you do that a lot). You could then use JavaScript to place the .disabled class on any link you want to disable.

				
					<a class="sidebar_link disabled" href="mylink.html">My Disabled Link</a>
				
			
				
					.disabled {
    pointer-events: none;
    text-decoration: line-through;
}
				
			

Example

My Disabled Link

We’d like to acknowledge that we learned a great deal of our coding from W3Schools and TutorialsPoint, borrowing heavily from their teaching process and excellent code examples. We highly recommend both sites to deepen your experience, and further your coding journey. We’re just hitting the basics here at 1SMARTchicken.

CSS
HTML
JavaScript
jQuery
PHP
SQL
WordPress

Why 1SMARTchicken?

This site was built and is maintained to benefit my autistic son.
See More →

My Son's Name is Johnny

He was diagnosed as autistic quite late, at age four...
His story

Buy Me a Coffee

Thanks for your support!

Feedback

If you see an error on the page or the code itself is incorrect or incomplete, or just plain wrong, please let us know. We’re always learning. NOTE: we do not sell your information and will not send you spam emails.