在我的页面上,我放了一些链接,但是我不想要任何下划线。那么,我该如何使用HTML去除这些下划线呢?
class="big-and-red"
是别名而不是分离。class="meaningful-domain-item"
然后css.meaningful-domain-item { //big and red }
就是分离。这个答案足以提醒我在我的CSS中使用哪个标签+1。 - Nathan Coopera {text-decoration: none; }
如果您想将此应用于特定链接,请给它们命名一个类名称,如nounderline
并执行以下操作:a.nounderline {text-decoration: none; }
这将仅应用于那些链接,并且不会影响所有其他链接。
此代码应放置在文档的 <head>
中或样式表中:
<head>
<style type="text/css">
a.nounderline {text-decoration: none; }
</style>
</head>
在HTML文档的主体部分:
<a href="#" class="nounderline">Link</a>
我建议使用:hover来避免在鼠标指针悬停在锚点上时出现下划线。
a:hover {
text-decoration:none;
}
Add this to your external style sheet (preferred):
a {text-decoration:none;}
Or add this to the <head>
of your HTML document:
<style type="text/css">
a {text-decoration:none;}
</style>
Or add it to the a
element itself (not recommended):
<!-- Add [ style="text-decoration:none;"] -->
<a href="http://example.com" style="text-decoration:none;">Text</a>
其他答案都提到了text-decoration。有时候你会使用WordPress主题或别人的CSS,链接会被其他方法下划线,这样text-decoration:none就无法关闭下划线。
另外我知道的两种下划线链接的方法是边框和box-shadow。要关闭它们:
border: none;
并且
box-shadow: none;
所有上述代码对我都不起作用。当我深入研究问题时,我意识到它之所以不起作用是因为我把样式放在超链接之后。当我把样式放在超链接之前时,它按预期工作了。
<a style="text-decoration:none" href="http://yoursite.com/">yoursite</a>
使用John Conde提供的解决方案更好,但有时使用外部CSS是不可能的。因此,您可以将以下内容添加到HTML标记中:
<a style="text-decoration:none;">My Link</a>
<style="text-decoration: none">
style
属性内联添加它,它仍然属于CSS。另外两个标签(presentation
和hyperlink
)也是完全有效的。在将来,请不要删除(或添加)问题的标签,除非有充分的理由这样做。谢谢! - 0b10011