Negative Numbers, Internet Explorer and Line Breaks

An end user submitted a bug report to me for a web application I work on. I’m glad that I didn’t simply dismiss it out of hand as a browser problem that I couldn’t solve, because I learned something.

A tester viewing a report we’re presenting in HTML commented that for sufficiently long negative numbers, Internet Explorer is inserting a line break between the minus sign and the number.

-131,344.11

It didn’t seem to make any sense until I realized that a minus is the same character as a hyphen, and that most text handlers have special rules for hyphens. And then I discovered this incredibly thorough discussion of word division in Internet Explorer.

Here is a fixed example, using the suggestion to replace the standard minus character with a non-breaking hyphen entity. For the web application, we implemented the fix in CSS, using the white-space:nowrap property.

‑131,344.11
Advertisements

#css, #ie-hacks, #internet-explorer