Debugging HTML Tables

Always the problem with HTML Tables is that td tags would not be correct due to carelessness in writing the markup language. so in order to debug the html tables, you could use backgroundcolor or bgcolor or background attribute for the table tag which sets the background color and border=1 attribute so that you could find what cell is missing.

<table border=1 bgcolor="pink">
 <tr><td>Row 1 cell 1</td><td>Row 1 cell 2</td></tr>
 <tr><td>Row 2 cell 1</td></tr>
</table>


Below is the output of the above table

Row 1 cell 1Row 1 cell 2
Row 2 cell 1

but still we are sure that one cell is missing somewhere.

<table border=1 bgcolor="black">
 <tr bgcolor="pink"><td>Row 1 cell 1</td><td>Row 1 cell 2</td></tr>
 <tr bgcolor="pink"><td>Row 2 cell 1</td></tr>
</table>


Below is the output of the above table

Row 1 cell 1Row 1 cell 2
Row 2 cell 1

Now you could see the problem. Now we solved it as below

<table border=1 bgcolor="black">
 <tr bgcolor="pink"><td>Row 1 cell 1</td><td>Row 1 cell 2</td></tr>
 <tr bgcolor="pink"><td>Row 2 cell 1</td><td>Row 2 cell 2</td></tr>
</table>


Below is the output of the above table

Row 1 cell 1Row 1 cell 2
Row 2 cell 1Row 2 cell 2

The problem might come if there is not text withing the cell.

MediaWiki

This page has been accessed 2,011 times.

This page was last modified 20:03, 22 June 2006.