table {
border: 1px solid #000;
border-width: 1px 0 0 1px; /* 上、左邊框 */
border-collapse: collapse;
text-align: center;
}
td, th {
border: 1px solid #000;
border-width: 0 1px 1px 0; /* 右、下邊框 */
text-align: left;
}
th {
text-align: center;
font-weight: 600;
font-size: 12px;
background-color: #F4F4F4;
}
border-collapse: collapse 合併相鄰邊框,避免雙線。<th> 置中加粗並加背景色,強化語意與可讀性。table, td, th {
border: 1px solid #000;
border-collapse: collapse;
}
若不需區分上左/右下邊框,此寫法最輕量,同樣通過標準驗證。
<table width="236">
<tr>
<th>項目</th><th>數值</th>
</tr>
<tr>
<td>A</td><td>100</td>
</tr>
</table>
表格仍是處理表格化資料的最佳語意標籤,配合 CSS 即能兼具標準與美觀。