Teez is absolutely correct that the problem is with the table-layout:fixed
.
What this styling does, is makes the table take it's column widths from the first row that is encountered, then starts generating the contents based purely on this. So in your example the first row is a colspan=3
so it just gives all columns equal width. Try swapping the rows round in your first example to see the effect. This also explains why your second example does work.
More information can be seen here: http://www.w3.org/TR/CSS2/tables.html#fixed-table-layout
In the fixed table layout algorithm, the width of each column is determined as follows:
- A column element with a value other than 'auto' for the 'width' property sets the width for that column.
- Otherwise, a cell in the first row with a value other than 'auto' for the 'width' property determines the width for that column. If the cell spans more than one column, the width is divided over the columns.
- Any remaining columns equally divide the remaining horizontal table space (minus borders or cell spacing).
[my bolding]
As a solution, you can add a <colgroup>
as the first entry inside the <table>
tag:
<colgroup>
<col style="width:50px;" />
<col style="width:50px;" />
<col style="width:300px;" />
</colgroup>
for example. As seen here.