从超链接div中的链接中删除下划线 [英] Remove underline from link within hyperlinked div
问题描述
我使用下面的html
I am using the html below
<a href=""><div class="logo"><span class="whologo">hyperlinked text </span>
</div></a>
我遇到的问题是,从span文本中删除下划线的唯一方法是使用 a:link {text-decoration:none;}
但这会从整个页面的所有链接中删除下划线
the problem i am having is that the only way to remove underline from the span text is using a:link{text-decoration:none;}
but this removes underlines from ALL links from the whole page
尝试
a.logo:link{text-decoration:none;}
但不会从span元素中删除超链接。
but it doesnt remove the hyperlink from the span element.
推荐答案
你有一个错误的层次结构和坏的元素选择。在你的case,最准确的CSS将是:
You have a wrong hierarchy there and bad element selection. In your case, the most accurate CSS would be:
a div.logo span.whologo {text-decoration:none;}
但我建议这种方法:
But I suggest this approach:
<div class="logo"><a href=""><span class="whologo">hyperlinked text </span></a>
>
And CSS:
div.logo a {text-decoration:none;}
或者如果需要的话可以包括span(但是如果span元素有下划线,就像Hans在注释中指出的那样):
Or include the span if needed (but only if the span element has underlines, like Hans pointed out in the comment):
div.logo a span.whologo {text-decoration:none;}
这篇关于从超链接div中的链接中删除下划线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!