Recently I answered a question and the OP wanted text-decoration: underline;
for the entire text wrapped inside the a
element, but not the one wrapped inside span
, so it was something like this
<a href="#"><span>Not Underline</span>Should Be Underlined</a>
So simply giving
span {
text-decoration: none;
}
doesn't remove the underline for the text wrapped inside a span
element
But this does remove the underline
span {
text-decoration: none;
display: inline-block;
}
So I made the span
an inline-block
and it worked, which is how I usually do it. But when it came to explanation I was not able to explain why doing this actually removes the underline where simply using text-decoration: none;
doesn't.
Demo
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…