Is it possible to stop a TD breaking on the minus sign of a value and instead make it break on the decimal point?
I have a table displaying decimal amounts from a database. Some of the amounts are large and need to wrap somehow.
At the moment, when a value exceeds my TD's width it get truncated as follows:
-
123456.00
But Is there any way to make it break as:
-12345
.00
without having to manually intervene and format the strings? i.e. can it be done in css or another way?
EDIT
Both of these work in Firefox, but not in IE8 (second and third columns are
<td>
-1234567​.89
</td>
<td>
-1234567<wbr>.89
</td>
If you want to prevent the text from wrapping, you can apply white-space: nowrap; Notice in HTML code example at the top of this article, there are actually two line breaks, one before the line of text and one after, which allow the text to be on its own line (in the code).
The task is to prevent the text in a table cell from wrapping using CSS. To achieve this we use white-space property of CSS. This property forces the contents of th to display in one line. There are many property values exists to the white-space function.
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.
An HTML table consists of one <table> element and one or more <tr>, <th>, and <td> elements. The <tr> element defines a table row, the <th> element defines a table header, and the <td> element defines a table cell. An HTML table may also include <caption>, <colgroup>, <thead>, <tfoot>, and <tbody> elements.
Try using the <wbr>
tag like so:
-123456<wbr>.00
To make it more browser compatible you can use this too: (ref)
​
<TD NOWRAP>
stops all linefeeds maybe what you search for?
Edit: And manualy linefeeds with <br>
!
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