3

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.

j08691
  • 204,283
  • 31
  • 260
  • 272
Steven Lu
  • 41,389
  • 58
  • 210
  • 364
  • Are you trying to do anything different that [this question](http://stackoverflow.com/questions/4457506/css-how-to-set-the-table-column-width-constant-regardless-of-the-amount-of-text) ? – Hisham Oct 17 '12 at 18:17

2 Answers2

4

Try adding table-layout: fixed; to your table's CSS declaration.

Kevin Boucher
  • 16,426
  • 3
  • 48
  • 55
4

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
Community
  • 1
  • 1
Reut Sharabani
  • 30,449
  • 6
  • 70
  • 88