Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the behavior when sum of widths of columns != table width?

I have a table with a fixed width of 800.

I noticed that when the column widths don't add up to 800, my browser (Chrome) will arbitrarily choose one column to increase in size (could be more than one, I'm not sure).

Also, when I make the sum of the widths of the columns > 800, then it just accepts it.

Is there a standard behavior of how a browser should behave when the sum of the widths of the columns do not equal the width of the table?

like image 261
steve8918 Avatar asked Nov 24 '11 02:11

steve8918


People also ask

How you can define columns of equal width?

On the Page Layout or Layout tab, click Columns. At the bottom of the list, choose More Columns. In the Columns dialog box, adjust the settings under Width and spacing to choose your column width and the spacing between columns. If you want columns of varying widths, deselect the checkbox next to Equal column width.

How do you fix column width in a table?

The width of the columns i.e. td in a table can be fixed very easily. This can be done by adding the width attribute in the <td> tag. If the width is not specified, the width of the column changes according to the change in the content. The specifications of width for the columns can be in pixels, or percentage.

How do you set column width in a table?

Change column width To change the width to a specific measurement, click a cell in the column that you want to resize. On the Layout tab, in the Cell Size group, click in the Table Column Width box, and then specify the options you want.

Does not specify column width?

10. Which of the following does not specify a column width? Explanation: We can specify column width in three ways i.e. Percentage, Fixed, Proportional. Fixed width is given in pixels.


1 Answers

Yes, it seems to be proper behavior.

According to the spec, user agents (browsers) are directed to "reflow" columns as necessary

If column widths prove to be too narrow for the contents of a particular table cell, user agents may choose to reflow the table.

http://www.w3.org/TR/html4/struct/tables.html#column-width

Also,

User agents may use any algorithm they wish to do so, and are free to prefer rendering speed over precision, except when the "fixed layout algorithm" is selected.

See more here

http://www.w3.org/TR/CSS2/tables.html#width-layout

like image 110
Jason Gennaro Avatar answered Oct 18 '22 21:10

Jason Gennaro