在 <table> 標籤上直接設定 width 與 height 屬性,即可固定表格的寬度與高度。單位預設為像素,也可使用百分比實現響應式佈局。
<table width="300" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>單元格內容</td>
</tr>
</table>
width="300":表格寬度 300 像素。height="200":表格高度 200 像素(可選)。border="0":隱藏邊框。cellspacing="0":單元格間距為 0。cellpadding="0":單元格內邊距為 0。現代開發建議改用 CSS 控制尺寸(如 table { width: 300px; height: 200px; }),以便樣式與結構分離,提升可維護性。