Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you control the minimum width of a table cell?

I have a need in a variety of cases to ensure a table cells don't shrink past a certain width. To accomplish this I've tried a number of options with varying results. Some of the options I've tried:

  • width on the td: works alright, but some browsers ignore it and it's not valid in HTML5
  • CSS width inside style="" or stylesheet: ignored by some browsers
  • image with width=X and height=1: causes the content of the td to be push up or down (by more than 1px).
  • div with width=X and height=1 and float:left: this seems to work the best at the moment, although it does push the content up or down slightly

Any other ideas?

I need to it work in anything, including IE6 :( but if there are solutions that don't work in IE6, but everything else, that'd be a start anyway :)

like image 640
Darryl Hein Avatar asked Nov 07 '10 02:11

Darryl Hein


1 Answers

You can't reliably control the width of a table cell. It's best to wrap the contents in a DIV (or any other block level elements) and target that element.

like image 96
Brandon Durham Avatar answered Oct 19 '22 23:10

Brandon Durham