Reputation: 178
I was wondering is there could be a trick in Css3 how to make a hyperlink loose its function, simply put, to disable the on click function ( so that it appears like a normal hyperlink but has no function like a paragraph) ?
Upvotes: 4
Views: 1395
Reputation: 1182
By any chance if you want this for the parent link of a dropdown menu, like:
<div class="dropdown">
<a href="#" class="dropdown-parent">Products</a>
<div class="dropdown-content">
<a href="#">Product 1</a>
<a href="#">Product 2</a>
<a href="#">Product 3</a>
</div>
</div>
May be you don't want to see # upon hovering the content, neither javascript:void(0).
Then just simply remove the href attribute in the parent link:
<a class="dropdown-parent">Products</a>
This is valid. ( ref: w3.org )
No need to use any css or js code for that.
For more detail, you can visit this page.
Upvotes: 0
Reputation: 4942
CSS only solution is not cross browser supported at current time. But it is possible using pointer-events: none;
a.disabled {
pointer-events: none;
}
And there is no need to set disabled link cursor to default, cause links with pointer-events: none;
has default cursor already.
Upvotes: 2
Reputation: 2201
<a href="http://example.com" class="inactive">Link</a>
.inactive {
pointer-events: none;
cursor: default;
}
The cursor:default
property is if you want the cursor to be just an arrow. If you want it to act like a link (with the "hand" cursor), then remove it.
Upvotes: 6