Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Table footer auto spanning across width of table

I have a table which has dynamic number of columns depending on data I receive. I have a tag which needs to spread across all columns independent of number of columns in a table.

<table>
<thead>
<tr>
<th><span>ColA</span></th>
<th><span>ColB</span></th>
<th rowspan='2'><span>Col<br/>  C</span></th>
</tr>
</thead>
<tbody>
</tbody>
<tfoot>
<tr>
<td>Footer content here</td>
</tr>
</tfoot>
</table>

EDIT colspan = 0 worked for me!

<td colspan='0'>Footer content here</td>

Works on FF, Did not work for Chrome, IE8 though :(

EDIT 2

colspan = '100%' This link solved crossbrowser problem https://stackoverflow.com/a/5028091/405117

like image 876
Vikram Avatar asked Sep 12 '12 14:09

Vikram


People also ask

How do you span an entire table width?

You need to set the margin of the body to 0 for the table to stretch the full width. Alternatively, you can set the margin of the table to a negative number as well. Save this answer.

Is Tbody required?

The TBODY end tag may always be safely omitted. The start tags for THEAD and TFOOT are required when the table head and foot sections are present respectively, but the corresponding end tags may always be safely omitted.


1 Answers

Use colspan="0"
By the way, your <tfoot> should be between <thead> and <tbody> tags.

EDIT: That practice, being recommended by W3C, is not cross-browser. Use carefully!

like image 138
albertedevigo Avatar answered Nov 09 '22 03:11

albertedevigo