Styling Links
Links have states: :link (unvisited), :visited, :hover and :active. Write them in that order (the LVHA rule) so later states override earlier ones correctly. :focus-visible shows keyboard focus.
You can remove the underline with text-decoration: none, but keep links recognisable through colour or another cue. Links can also be styled to look like buttons.
Example
<style>
a { color: #1d4ed8; text-decoration: none; }
a:hover { text-decoration: underline; color: #1e3a8a; }
a:active { color: crimson; }
a.btn { display: inline-block; padding: 8px 16px; background: #1d4ed8; color: white; border-radius: 6px; }
a.btn:hover { background: #1e40af; text-decoration: none; }
</style>
<p><a href="#">A plain link</a></p>
<p><a class="btn" href="#">Button link</a></p>Exercise
Underline the link only when hovered.
a:hover { text-decoration: ; }
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.