2016-10-04 127 views
-8

如何從鏈接中刪除下劃線?這是我的代碼 我嘗試在裏面輸入一些代碼,但仍然沒有工作如何刪除html中鏈接的下劃線

@charset "utf-8"; 
 
/* CSS Document */ 
 
.top { 
 
    color:black; 
 
    font-family:Calibri; 
 
    text-decoration:none; 
 
} 
 

 
table { 
 

 
}
<table> 
 
    <tr> 
 
    <td><a href="Home.html"><p class="top">Home</p></a></td> 
 
    </tr> 
 
</table>

回答

1

你必須設置text-decoration: none<a>標籤本身,而不是對<p>這是它裏面。

1

應該是這樣的:

a { 
    text-decoration: none; 
} 
0

我用a標籤更換.top

@charset "utf-8"; 
 
/* CSS Document */ 
 
a { 
 
    color:black; 
 
    font-family:Calibri; 
 
    text-decoration:none; 
 
} 
 

 
table { 
 

 
}
<!doctype html> 
 
<html> 
 
<head> 
 
<meta charset="utf-8"> 
 
<title>Home</title> 
 
<link rel="stylesheet" type="text/css" href="css.css">`enter code here` 
 

 
</head> 
 

 
<body> 
 
<table> 
 
    <tr> 
 
     <td><a href="Home.html"><p class="top">Home</p></a></td> 
 
    </tr> 
 
</table> 
 
</body> 
 
</html>

2

.top類變化爲p標籤的風格,但它是a標記,設置text-decoration,所以你必須指定或添加到您的a標籤另一個類,並設置它的text-decoration屬性。

一種可能的方法:

<table> 
    <tr> 
    <td> 
     <a href="Home.html" class="no-underline"> 
     <p class="top">Home</p> 
     </a> 
    </td> 
    </tr> 
</table> 

.no-underline { 
    text-decoration: none; 
}