I have an <a id="javascriptlink">
tag, without href. Its action handled by jquery onclick.
So, I want to put in css a:link {text-decoration: underline;}
and a:hover {text-decoration: none;}
to make it look like a link.
However, the anchor underline seems to only work when href attribute is presented. Any idea?
Yes, it is valid to use the anchor tag without a href attribute. If the a element has no href attribute, then the element represents a placeholder for where a link might otherwise have been placed, if it had been relevant, consisting of just the element's contents.
Complete HTML/CSS Course 2022 To remove underline from a link in HTML, use the CSS property text-decoration. Use it with the style attribute. The style attribute specifies an inline style for an element. Use the style attribute with the CSS property text-decoration to remove underline from a link in HTML.
Just add the href attribute but make the link do nothing by canceling the event.
<a href="#" onclick="event.preventDefault(); return false;" id="javascriptlink">
a{
text-decoration: underline;
cursor: pointer;
}
a:hover{
text-decoration: none;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With