Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create underline effect on hovered links in CSS?

Tags:

html

css

I'm trying to achieve styling like this:

bbc.com with arrows pointing to underlined menu entries

How do I to create that effect using CSS?

like image 880
sounak07 Avatar asked Oct 31 '25 15:10

sounak07


2 Answers

a{
   text-decoration:none;
}

a:hover {
   text-decoration:underline;
}

This should work for links, however the effect in the picture seems to be made with the link's container border:

div.yourcontainer:hover{
    border-bottom:2px solid red;
}

This should work ^^

like image 188
IlReDelleFinte Avatar answered Nov 02 '25 06:11

IlReDelleFinte


By using :hover and setting a border-bottom. Something like this

ul{
  list-style: none;
  padding: 0;
  margin: 0;
}
ul li{
  float: left;
  margin: 0 5px;
}
ul li a{
  text-decoration:none;
  color: black;
}
ul li:hover{
  border-bottom: 2px solid red;
}
<ul>
  <li><a href="">Home</a></li>
  <li><a href="">About</a></li>
  <li><a href="">Contact</a></li>
</ul>
like image 45
Gustaf Gunér Avatar answered Nov 02 '25 05:11

Gustaf Gunér



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!