1

If I have a table with only 1 cell, and I set its width and height in its inline style to be a certain amount of pixels (fixed not percentage). What CSS property or attribute is there that will ensure the dimensions on the cell does not increase no matter how much content there is in it. I noticed on my cell, that when I add text, the dimensions still change even though I set it.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
omega
  • 40,311
  • 81
  • 251
  • 474

2 Answers2

3

You want to use the overflow property. In this case, it seems you want it hidden:

.cell1 {overflow: hidden;}

Read here for more options.

Also found this post indicating that you need to add table-layout: fixed; and white-space: nowrap; in addition to the overflow property.

Community
  • 1
  • 1
Kermit
  • 33,827
  • 13
  • 85
  • 121
3

Set the table-layout to fixed and the overflow to hidden.

table {
    overflow:hidden;
    table-layout:fixed;
}​

jsFiddle example

j08691
  • 204,283
  • 31
  • 260
  • 272