Water Cooler v2
Water Cooler v2

Reputation: 33880

Make an HTML table's column span all the columns

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.

Upvotes: 14

Views: 32497

Answers (4)

shyam_
shyam_

Reputation: 2480

you can just set the maximum possible no for that many column wont be available in the table

like if you have max 5 column, just set colspan="6" or even more.

Upvotes: -1

Bruce Patin
Bruce Patin

Reputation: 2087

colspan="100%" seems to work well in IE 10, Firefox 26 and Chrome 31.

Upvotes: -1

you must specify how many columns you want to span eg: clospan ="3"

Upvotes: -1

Alex W
Alex W

Reputation: 38253

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.

Upvotes: 20

Related Questions