Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stop html table cell breaking on minus sign and instead on decimal point?

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&#8203;.89
</td>
<td>
 -1234567<wbr>.89
</td>

enter image description here

like image 756
BlueChippy Avatar asked Oct 19 '11 08:10

BlueChippy


People also ask

How do I stop text wrapping in HTML table?

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).

How do you stop a cell from wrapping in a table?

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.

How do you wrap text in a table cell in HTML?

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.

What is TR TH and TD in HTML?

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.


2 Answers

Try using the <wbr> tag like so:

-123456<wbr>.00

To make it more browser compatible you can use this too: (ref)

&#8203;
like image 91
472084 Avatar answered Oct 13 '22 00:10

472084


<TD NOWRAP> stops all linefeeds maybe what you search for?

Edit: And manualy linefeeds with <br>!

like image 27
San Avatar answered Oct 12 '22 22:10

San