How to set automatic minimum width in a column using css?

I am trying to create a table where two of the columns are the smallest width needed to hold the content, and the third column will be as wide as possible. I know how wide the two columns will be and they won't change so much, but I would prefer as little hard coding width as possible.

Here is what I got:

​<table width="100%">
    <tr>
        <td align="left" style="width:auto;">
            123 123 123 123 123
        </td>
        <td align="center">
            bla bla
        </td>
        <td align="right" style="width:auto;">
            hello
        </td>
    </tr>
</table>​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​

The first and last columns take up more space than necessary, causing the middle column to not center. Is there a way to do this, or should I just encode the width?

Edit: The answer is simple. Here is the complete answer if it helps anyone else:

​<table width="100%">
    <tr>
        <td align="left" style="white-space:nowrap;">
            123 123 123 123 123
        </td>
        <td align="center" width="100%">
            bla bla
        </td>
        <td align="right">
            hello
        </td>
    </tr>
</table>​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​
+5
source share
2 answers

Well, you have a table set to 100% width .. it should expand something :-)

+1

? 100% , , .

0

All Articles