Html – Make HTML Column Wider As Inner Div Expands


Please consider the following:

<td style="width: 500px;">
    <div style="width: 400px;">SomeContent</div>

For some reason, the column that contains a div will not expand to 500px as the style suggests.

Do you know how to get the td to honor the width that I am specifying in the style?

Best Solution

In theory, you can use the min-width and max-width styles. In practice, some popular browsers ignore these styles. In this case you have explicitly declared a width of 400, so it should always equal 400 unless acted upon by a child growing or a parent shrinking. You could runat-"server" and programatically determine the width attribute based on content size, or you could play with the overflow style, or put it in a Panel with a horizontal scrollbar.