[英]How to add two columns with one header and textbox in each in html table
[英]Can I have one HTML table header be over two table columns? Like merge and center in Excel?
我希望有一個表頭並排在兩個表列的中心。 這可能嗎?
<th colspan="2">. This .</th>
有點推斷......
<table>
<thead>
<tr>
<th>Single Column</th>
<th colspan="2">Double Column</th>
</tr>
</thead>
<tbody>
<tr>
<td>Column One</td>
<td>Column Two</td>
<td>Column Three</td>
</tr>
</tbody>
</table>
這應該足以讓你工作。
如果您只有2列,那么我建議使用<caption>
。 否則,請按照其他答案中的建議使用colspan。
<table>
<caption>This will span all columns.</caption>
<tr><td>column one</td><td>column two</td></tr>
</table>
當然。 請參閱此頁面。 您正在尋找表頭單元格的名為colspan
屬性。
我們可以更好地做到這一點。
<table border="1">
<tr>
<th colspan="1" scope="colgroup">Test Heading</th>
<th colspan="3" scope="colgroup">Mars</th>
<th colspan="3" scope="colgroup">Venus</th>
<th colspan="3" scope="colgroup">Test</th>
</tr>
<tr>
<th rowspan="2"></th>
<th scope="col">Produced</th>
<th scope="col">Sold</th>
<th scope="col">Sold</th>
<th scope="col">Produced</th>
<th scope="col">Sold</th>
<th scope="col">Sold</th>
<th scope="col">Test 1</th>
<th scope="col">Test 2</th>
<th scope="col">Test 3</th>
</tr>
</table>
如果您想了解更多信息,請訪問W3.org上的表格參考 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.