Stores <td>
contain table with mulitple rows. A store can have mulitple
stores (rows).
See Example: https://jsfiddle.net/ak3wtkak/1/
The width of Stores and Quantity (<th>
) columns should be same for mulitple rows on the second table. How to fix this or what is alternative approach?
<table border="1" width="100%">
<thead>
<tr>
<th style="width:300px">Product</th>
<th>Barcode</th>
<th>Stores</th>
<th class="middle">Quantity</th>
</tr>
</thead>
<tbody>
<tr>
<td>
Item 1
</td>
<td>12345</td>
<td colspan="3">
<table border="1" width="100%">
<tbody>
<tr>
<td>Store Name 1</td>
<td class="middle">4</td>
</tr>
<tr>
<td>Store Name 2</td>
<td class="middle">4</td>
</tr>
<tr>
<td>Store Name 3</td>
<td class="middle">4</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
The rowspan attribute in HTML specifies the number of rows a cell should span. That is if a row spans two rows, it means it will take up the space of two rows in that table. It allows the single table cell to span the height of more than one cell or row.
You can merge two or more table cells in a column using the colspan attribute in a <td> HTML tag (table data). To merge two or more row cells, use the rowspan attribute.
The HTML rowspan attribute define the number of rows a cell of a table should span in an HTML document. It can only be applied on td or th HTML element.
In the table, click the cell that you want to split. Click the Layout tab. In the Merge group, click Split Cells. In the Split Cells dialog, select the number of columns and rows that you want and then click OK.
You have to use rowspan. Make the first 2 rows with rowspan of 3.
<table border="1" width="100%">
<thead>
<tr>
<th style="width:300px">Product</th>
<th>Barcode</th>
<th>Stores</th>
<th class="middle">Quantity</th>
</tr>
</thead>
<tbody>
<tr>
<td rowspan="3">Item 1</td>
<td rowspan="3">12345</td>
<td>Store Name 1</td>
<td>4</td>
</tr>
<tr>
<td>Store Name 2</td>
<td>4</td>
</tr>
<tr>
<td>Store Name 3</td>
<td>4</td>
</tr>
</tbody>
</table>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With