Table cell (TD) dynamically sizing to width of longest word in column. What style causes this?

css, html, layout

Solution

First of all, check this out:

Fixed Table Cell Width

Now,

for fixed cell size (`<td>`) use:

<col width="50px"/>

before your

<tr>

Alternatively, use:

<table width = 100>

OR

<table style="width:100px">

To fix the table size.

The "break word" value for "word wrap" property in your css is useful in these cases:

word-wrap:break-word

Problem

Webkit inspector is unable to tell me why my table cells are not obeying the `width` style. I can get them to either stretch to fit the entire line (by setting `white-space: nowrap` or to stretch to fit the longest word, but I just want the cells to be some number of pixels wide.

Original source

Related problems