Skip to content Skip to sidebar Skip to footer

Table Cell Width Issue

I have a table with 2 rows where i need varying cell width as

Solution 1:

to do this with one table you need to introduce more columns and then get the column widths by using colspan so you can get the combined widths you require

to get this to work well across browser you will possibly need to use the <col> and <colgroup> elements : http://www.w3.org/TR/html401/struct/tables.html#h-11.2.4

<bodybgcolor="#14B3D9"><tablewidth="100%"border="1"bgcolor="#ffffff"><colgroup><colwidth="25%"><colwidth="25%"><colwidth="25%"><colwidth="5%"><colwidth="20%"></colgroup><tr><td>25</td><tdcolspan="2">50</td><tdcolspan="2">25</td></tr><tr><tdcolspan="2">50</td><tdcolspan="2">30</td><td>20</td></tr></table></body>

Solution 2:

Actually, you can just have each tr set to display:block, and it will allow you to set different column widths for each row.

Solution 3:

You can use nth:child

However it will apply to all rows. This will be relative and not absolute.

tr>:nth-child(6){ 
    width: 20%;
    }
    tr>:nth-child(7){ 
    width: 80%;
    }

Post a Comment for "Table Cell Width Issue"