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?
Use the word joiner character ( ⁠ ) around the hyphen.
The <nobr> HTML element prevents the text it contains from automatically wrapping across multiple lines, potentially resulting in the user having to scroll horizontally to see the entire width of the text.
There are two methods to wrap table cell <td> content using CSS which are given below: Using word-wrap property: This property is used to allow long words to break and wrap onto the next line. Using word-break property: This property is used to specify how to break the word when the word reached at end of the line.
The <br> tag inserts a single line break. The <br> tag is useful for writing addresses or poems. The <br> tag is an empty tag which means that it has no end tag.
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>
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With