Edited
My question is completely different from the duplicate question. I am talking about the underline should continue till the end of the text. No matter whether it’s divided into one, two or three line
I have to show the underline below the anchor tag and I have tried the code below but am getting one issue. I have set the width 300px to the ul tag and anchor text divided into two parts but the underline not showing the divided text.
Output
Expected Output
I have to show underline below the "of mentoring" also
ul {
width: 300px
}
ul,
li {
list-style: none;
}
a {
text-decoration: none;
}
ul li a {
position: relative;
font-size: 28px;
line-height: 32px;
color: #000;
}
ul li a:after {
content: "";
background-color: red;
width: 100%;
height: 10px;
display: block;
position: absolute;
bottom: 5px;
z-index: -1;
}
<ul>
<li>
<a href="">The role of mentoring</a>
</li>
<li>
<a href="">Research backed benefits of mentoring</a>
</li>
</ul>
2
Answers
Since your underline is
absolute
, this should do the trick.Note that this is not the optimal solution since it strips the HTML tags inside the
a
element.This can be achieved using
text-decoration
andtext-underline-offset
👇: