Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS column width in tables Reply To: column width in tables

#158148
Merri
Participant

You can give the table element table-layout: fixed; which will make fixed sizes more explicit than they usually are (but those sizes are still relative to each other). It also makes percentages be based on the space that is available after fixed sizes are done width.

So if table has a width of 700px and you have three columns, with two columns with 90px and one with 100%:

  • table-layout: auto; (the default) gives minimum width possible to the 90px columns based on their content and everything it can to the 100% column. If there is no content in the 90px columns then those columns will end up having 0px width.
  • table-layout: fixed; gives 90px columns the requested 90px width and 100% will get 700 – 90 – 90 = 520px of size.

As a warning I think Opera 12.16 (which still appears to be to most widespread version of Opera) has issues understanding fixed tables correctly.