I have a table structure similar to below:
<tr>
<td colspan="5">
TEST
</td>
</tr>
<tr id="abcd_<?php echo $id; ?>" style="display: none;">
<td colspan="5">
<span id="hidtb_<?php echo $id; ?>"></span>
</td>
</tr>
The table is within a loop and the value of $id
changes. The second tr
is set to display : block
using javascript. But the <td colspan="5">
is not covering all the five <td>
s, instead only one.
Why my colspan
is not working?
Usage: It can be used with <td> and <th> element while creating an HTML Table. Attribute Values: It contains a value i.e number Which specify the number of columns that a cell should span.
The colspan attribute defines the number of columns a cell should span.
Note: colspan=”0″ tells the browser to span the cell to the last column of the column group (colgroup). <td>: The colspan attribute when used with <td> tag determines the number of standard cells it should span.
Table cells can span across more than one column or row. The attributes COLSPAN (“how many across”) and ROWSPAN (“how many down”) indicate how many columns or rows a cell should take up.
This is the problem with display: block
.
Please refer the below link http://thedesignspace.net/MT2archives/000376.html#.UUrg3FfCd1u
If you are hiding tr
, then use display: table-row
instead of display: block
to display that tr
.
If you are hiding td
, then use display: table-cell
instead of display: block
to display that td
.
Use table-row
, no block
when styling a tr
. Perfect!
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