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
  • 197,815
  • 30
  • 248
  • 265
Steven Lu
  • 39,229
  • 55
  • 195
  • 348
  • 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
  • 15,718
  • 3
  • 43
  • 54
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
  • 29,003
  • 5
  • 68
  • 85