Search code examples
htmlcsswidthcss-tables

Css table column width "as is"


Is there any way to specify table column width "as is". In other words, I want a column to have exact width its content takes to display.


Solution

  • That should be the default case.

    <!-- "table-layout" is "auto" by default as well, just to force it -->
    <table border="1" style="table-layout:auto;">
        <tr>
            <td>Column 1</td>
            <td>Column 2</td>
        </tr>
    </table>
    

    This is how it looks like