To hide the underline from a link in CSS, you can use the text-decoration
property and set its value to none
. This will remove the default underline that browsers apply to anchor (<a>
) elements.
Here's how you can do it:
a.no-underline {
text-decoration: none;
}
Then, in your HTML:
<a href="#" class="no-underline">This link will not have an underline</a>
Or, if you want to remove the underline from all links globally:
a {
text-decoration: none;
}
Note: While it's common to remove underlines from links, especially in navigation menus or buttons, it's essential to ensure that links are still distinguishable from regular text. This is important for usability and accessibility. You might want to use other styles, like changing the color or adding a hover effect, to indicate that the text is clickable.