I have a number of tables with the same columns and it would look a lot nicer if they shared the same column widths. Is such a thing possible? Putting them in the same table with some rows with no borders between them isn't an option.
Edit: Yeah I'm aware I can fix the widths myself but I was hoping for something that would tie in to the browser's column width algorithm but simply tied two or more tables together for the purpose of doing that layout.
I didn't think such a thing was possible but I thought I'd check just in case.
Just add style="table-layout: fixed ; width: 100%;" inside <table> tag and also if you do not specify any styles and add just style=" width: 100%;" inside <table> You will be able to resolve it.
If you set the style table-layout: fixed; on your table, you can override the browser's automatic column resizing. The browser will then set column widths based on the width of cells in the first row of the table. Change your to and remove the inside of it, and then set fixed widths for the cells in .
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.
Table data defaults to left alignment; table headers to center. In order to change the alignment in one cell, insert the appropriate "ALIGN=" attribute within the code for that cell. In order to change the alignment in all cells in a row, insert the appropriate alignment attribute within the code for that row.
If you're not too picky about which column widths the browser comes up with, as long as they're the same across different tables, you can use the CSS table-layout
property (supported by all major browsers) in combination with a table width:
table { table-layout: fixed; width: 100%; }
This causes all columns (without a specified width) to have the same width, regardless of the table content.
It's only possible if you can fix-width the columns. If you can set a fixed width then some css like this should work:
td { width: 25%; }
You can customize each columns width like this:
<table> <tr> <td class="col1">...</td> <td class="col2">...</td> </tr> </table> ... <table> <tr> <td class="col1">...</td> <td class="col2">...</td> </tr> </table>
and then specify the widths like this:
.col1 { width: 25%; } .col2 { width: 75%; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With