0

Is there a way I can specify the margin of a <td> so that the width of automatically adjusts to make the table as wide as its parent (width: 100%;)?

Robert Harvey
  • 178,213
  • 47
  • 333
  • 501
  • Does this answer your question? [CSS table column autowidth](https://stackoverflow.com/questions/4757844/css-table-column-autowidth) – Robert Harvey Dec 26 '19 at 16:51
  • 1
    The title and body of your question do not match. The title asks about setting the width of a table cell to auto (whatever that means), whereas the body asks something about setting the margin of a table cell (which doesn't exist) so the width of the table is as wide as its parent. The current proposed duplicate answers the title question. – Heretic Monkey Dec 26 '19 at 16:58

1 Answers1

1

By creating a table in HTML for example like:

<table>
    <thead>
        <tr>
            <td>Header</td>
            <td class="smallCell">Small Fit</td>
            <td>Header</td>
        </tr>
    </thead>

and for adjusting the width with CSS do add like:

table
{
    width: 100%;
    border-collapse: collapse;
}
//enter according to the size requirement