Reputation: 5585
I've got a very basic question. But I can not get this working correctly.
This is my table structure.
<table style="width:100%;">
<tr style="background-color:#000;">
<td style="color:#fff;">
Fruits
</td>
</tr>
<tr>
<td>
Lychee
</td>
<td>
Mango
</td>
<td>
Papaya
</td>
<td>
Banana
</td>
</tr>
</table>
How can I get he output to be as
Upvotes: 2
Views: 49
Reputation: 9439
Use <td style="color:#fff;" colspan="4">
see fiddle https://jsfiddle.net/DIRTY_SMITH/3oo2jmko/1/
<table style="width:100%;">
<tr style="background-color:#000;">
<td style="color:#fff;" colspan="4">
Fruits
</td>
</tr>
<tr>
<td>
Lychee
</td>
<td>
Mango
</td>
<td>
Papaya
</td>
<td>
Banana
</td>
</tr>
</table>
Upvotes: 0
Reputation: 3330
Use the colspan attribute. Colspan allows one td
to span many columns.
<table style="width:100%;">
<tr style="background-color:#000;">
<td style="color:#fff;" colspan="4">
Fruits
</td>
</tr>
<tr>
<td>
Lychee
</td>
<td>
Mango
</td>
<td>
Papaya
</td>
<td>
Banana
</td>
</tr>
</table>
Upvotes: 2