I have a document containing a table like this:
<table> <tr> <td> Word </td> <td> Definition </td> </tr> <tr> <td> Word </td> <td> Definition </td> </tr> <tr> <td> Word </td> <td> Definition </td> </tr> </table>
Using CSS, I need to set all of the cells to 50% width, with text in the left "column" being right-aligned and text in the left column being left-aligned. I've tried many different options, e.g. width: 50%; text-align: left
, but the results are always unusual. The results should look like this:
_________________________ | word | definition | |____________|____________| | word | definition | |____________|____________|
How can I set equal-width cells in a two-column table in CSS with everything aligned to the middle?
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.
You can set table-layout: fixed;
on your table. Using this you can override the browser's automatic column resizing. Then your browser sets the column width of first column to all.
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