HTML Tables - How to make IE not break lines at hyphens

Greg picture Greg · Oct 14, 2009 · Viewed 10.8k times · Source

I have some table cells containing dates formatted like this: 2009-01-01. I.E 7 seems to be breaking these into two lines at the hyphen. Is there any way to turn this off?

Answer

Sampson picture Sampson · Oct 14, 2009

You are looking for the white-space property, which affords you control over how white space and line-breaks affect the content of your element. To collapse white space sequences, but prevent line-breaks, you can use the nowrap value:

.dates {
    white-space: nowrap;
}
<td class="dates">2009-01-01</td>