Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Table td colspan not working for tr with ids

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?

final output table

like image 683
Nitish Avatar asked Nov 05 '13 08:11

Nitish


People also ask

Can Colspan be used with TR?

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.

What does td colspan do?

The colspan attribute defines the number of columns a cell should span.

What is the syntax of Colspan?

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.

What effect does the Colspan have on the table data?

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.


1 Answers

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!

like image 179
Legionar Avatar answered Sep 21 '22 17:09

Legionar