Disable Anchor Tag Clicks with CSS
You can prevent a link from behaving like a link — doing nothing when clicked — using the CSS pointer-events property. This is useful when you want to deactivate navigation links conditionally based on the current page context.
Examples
Deactivate a navigation link only on a specific page by combining a body ID with a nav class:
/* Disable the Home nav link only on the homepage (#home body) */
#home nav .home > a {
pointer-events: none;
cursor: default;
}
Steps
1. Add a unique ID to the <body> tag on the page where you want the link disabled (e.g., id="home").
2. Ensure the navigation link has a class you can target (e.g., class="home" on the <li> element).
3. Apply the CSS rule above in your stylesheet.
Notes
pointer-events: none is supported in Firefox 3.6+, Safari 3+, and Chrome 5+. It is not supported in older Opera or Internet Explorer versions. CMS platforms like WordPress provide a body_class() function that automatically adds context-specific classes to the body element, making it easy to scope rules like this.