13

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.

Vektor
  • 560
  • 4
  • 15
Water Cooler v2
  • 32,724
  • 54
  • 166
  • 336
  • 3
    Could you set colspan to the number of columns in the table? – khalid13 Oct 23 '13 at 14:09
  • 1
    possible duplicate of [Colspan all columns](http://stackoverflow.com/questions/398734/colspan-all-columns) – Paul D. Waite Oct 23 '13 at 14:11
  • 1
    Failing that, could you set the colspan value to 32767 or some other implausibly high number? – Richard A. Oct 23 '13 at 14:12
  • 3
    Note that [`colspan="0"` isn't currently allowed by the HTML spec](http://www.w3.org/html/wg/drafts/html/master/tabular-data.html#attr-tdth-colspan). – Paul D. Waite Oct 23 '13 at 14:12
  • 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 canot set the colspan to a fixed number equal to the total number of columns because the number of columns is dynamic. – Water Cooler v2 Oct 23 '13 at 14:13
  • "I canot set the colspan to a fixed number equal to the total number of columns because the number of columns is dynamic." - You *can*, although I can imagine it might be a lot of work. – Paul D. Waite Oct 23 '13 at 14:14
  • 1
    *You can, although I can imagine it might be a lot of work.* @PaulD.Waite: Thank you. That did the trick. :-) – Water Cooler v2 Oct 23 '13 at 14:20

4 Answers4

20

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.

Alex W
  • 37,233
  • 13
  • 109
  • 109
-1

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

-1

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.

shyam_
  • 2,370
  • 1
  • 27
  • 50
-2

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

Bruce Patin
  • 2,049
  • 1
  • 12
  • 7