用 css 的 border 解決
table {?
border-collapse: collapse; ?//切記是 <table> 的屬性,而非 <td> 的.
}
border-collapse中的 collapse 和 separate 值,定義為collapse時,邊框會重疊在壹起。定義為separate時單元格邊框之間會有間隙。不定義時默認為separate。
cus:cellpadding,cellspacing都是廢棄的屬性了,早已不推薦使用,最新的html5裏已經徹底去掉了這些表現型的屬性。
擴展資料
html5中不再支持table的cellspacing和cellpadding屬性
如果現在開始用html5的聲明來寫頁面時,會發現在定義table的cellspacing和cellpadding時被提示該屬性已過時或者提示非法屬性。具體原因是在html5中table標簽的這兩個屬性已經被移除,需要定義邊框之類的時應該使用css的寫法。
具體實現如下:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Html5 Table Test</title>
<style type="text/css">
table{ border-collapse:collapse; border:solid 1px Black; }
table td{ width:50px; height:20px;? border:solid 1px Black; padding:5px;}
</style>
</head>
<body>
<table>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
</table>
</body>
</html>