[thelist] nowrap no way no how

MRC webmaster at equilon-mrc.com
Mon Feb 11 15:51:12 CST 2002


Matt,

> Is there a way, via CSS, to get a table cell to never wrap, no matter
> what, and not to enlarge the table either? Sound impossible, I know, but
> what I'd really like is for the table cell to cut off the overrun text,
> like a grid in an app does. This only needs to work in PC/IE. Any
> suggestions? :)

    It can be done in IE 5.5 and up:

table {
   table-layout: fixed ;
}
td {
   white-space: nowrap ;
   overflow: hidden ;
}

* "table-layout: fixed" is required to enforce the width of the table (by
default, columns are given an equal width, although you can override this by
explicitly setting widths on your tds or on associated col elements)

* "white-space: nowrap" prevents the text from wrapping to the next line
within the td

* "overflow: hidden" lops off the text that doesn't fit within the visible
portion of the td

    IIRC, if you employed divs within your tds, you could avoid the need for
the white-space property, which would allow this to work for IE 5, as well,
although additional tinkering would likely be required.

James Aylard




More information about the thelist mailing list