Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

CSS Image having border-bottom when I don't want to

made a sort-of custom underline in my html site using

a:hover {
 border-bottom: 2px solid red;
}

but this also appears on images with links, how can I stop this. (also if this is a dumb question sorry I’m new)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The cleanest solution would be to apply class to your a tag.

a.simple-link:hover {
 border-bottom: 2px solid red;
}
<div>
  <a class="simple-link" href="">Link</a>
  <img src="https://via.placeholder.com/150">
  <a href="" class="nested-link">
    <img src="https://via.placeholder.com/150">
  </a>
</div>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading