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?
You could give the table cell a width that's bigger than the width of the datestring.
You could try nowrap.
<td style="white-space:nowrap;">Hello - World</td>
or
<td nowrap>Hello - World</td>
I'm sure there's a better CSS way but the old way is with a no-break: <nobr>...</nobr>
but using no-break will cause nothing to go to the next line.
Another way is to use a Non-breaking hyphen. This way, you can still get wrapping, just not at the hyphen.
Use this CSS:
.nowrap {
white-space: nowrap;
}
Wrap your dates like: <span class="nowrap">2009-01-01</span>
.
Edit: the advantage of this solution over others is that it gives you more precise control over what should or should not wrap. Your cells may still wrap for spaces and other hyphens, outside the span.
This is NOT the correct way of answering your question, but this is how I do it:
<td>Hello - World</td>
I like this method better because you do not need to add a <style>
or class attribute. Also, it makes the text one string so that it cannot be line wrapped by the browser.
Like I said, most people would disagree, but I think this is where a practical solution is better than the standards solution.