Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make an HTML table's column span all the columns

Tags:

html

css

I have an HTML table and the CSS property table-layout is set to fixed.

I want one of the cells in the table, the only cell in a particular row, to span all the columns in the table, i.e to fill the entire width of the table.

When I use:

<td colspan = "0" id = "tdPager">

It works with FireFox v24 and IE 9 and above but does not work with Internet Explorer 8 or below and any version of Chrome.

How do I make the column span the entire table width in all browsers?

I have tried all -- setting the colspan to the values "*", "100%" and even a number higher than the total number of columns but it produces a horrid effect on all browsers. All the columns in the rest of the rows get really thin. I cannot set the colspan to a fixed number equal to the total number of columns because the number of columns is dynamic.

like image 739
Water Cooler v2 Avatar asked Oct 23 '13 14:10

Water Cooler v2


1 Answers

You are using it incorrectly by setting it to 0.

You need to set the colspan equal to the maximum number of columns that you have in any row of your table.

So, if your table has 6 columns in row 5 and that is the most, then you would set colspan="6".

If the number of columns is dynamic, then you need to set the colspan dynamically.

like image 198
Alex W Avatar answered Oct 25 '22 19:10

Alex W