[英]How to remove underline from a link in HTML?
在我的頁面中,我已經放置了一些我不想要任何行的鏈接,因此,如何使用HTML刪除它?
這將刪除所有鏈接的所有下划線:
a {text-decoration: none; }
如果您有要應用此功能的特定鏈接,請為其提供類名稱,例如nounderline
並執行以下操作:
a.nounderline {text-decoration: none; }
這僅適用於那些鏈接,並使所有其他鏈接不受影響。
此代碼屬於文檔的<head>
或樣式表:
<head>
<style type="text/css">
a.nounderline {text-decoration: none; }
</style>
</head>
並在身體:
<a href="#" class="nounderline">Link</a>
我建議使用:懸停以避免下划線,如果鼠標指針在錨點上方
a:hover {
text-decoration:none;
}
將其添加到外部樣式表( 首選 ):
a {text-decoration:none;}
或者將其添加到HTML文檔的<head>
:
<style type="text/css"> a {text-decoration:none;} </style>
或者將其添加到a
元素本身( 不推薦 ):
<!-- Add [ style="text-decoration:none;"] --> <a href="http://example.com" style="text-decoration:none;">Text</a>
其他答案都提到文字裝飾。 有時您使用Wordpress主題或其他人的CSS,其中鏈接用其他方法加下划線,因此text-decoration:none不會關閉下划線。
邊框和盒子陰影是我知道用於強調鏈接的另外兩種方法。 關閉這些:
border: none;
和
box-shadow: none;
以下不是最佳做法,但有時可證明是有用的
最好使用John Conde提供的解決方案,但有時候,使用外部CSS是不可能的。 因此,您可以將以下內容添加到HTML標記中:
<a style="text-decoration:none;">My Link</a>
<style="text-decoration: none">
上面的代碼就足夠了。只需將其粘貼到要刪除下划線的鏈接中即可。
所有上述代碼對我都不起作用。 當我深入研究這個問題時,我意識到它不起作用,因為我在href之后放置了這個樣式。 當我在href之前放置樣式時,它按預期工作。
<a style="text-decoration:none" href="http://yoursite.com/">yoursite</a>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.