1

Firefox attaches the space after a word to the word itself, which makes it wrap differently across browsers. I made a WYSIWYG text editor where this matters a lot. This code displays differently on Firefox versus Chrome (correct):

<div style='white-space: pre-wrap; width: 10ch; background: red; font-family: monospace;'>0000000 00 0</div>

Fiddle here: http://jsfiddle.net/57ZMq/3/

I experimented with other white-space modes, but they had worse problems, e.g. with double-spaces after periods. Is there any way to convince Firefox to wrap words not considering the space(s) that follow them, while also not putting the spaces onto the next? Thanks!

4
  • According to this article, the WebKit does not support the ch unit (lea.verou.me/2012/02/…). Perhaps use a different unit of measure? By the way, this doesn't display as you intend in Chrome either.
    – Sablefoste
    May 6, 2014 at 21:26
  • Thanks, but that's an old article and Chrome/Safari do support it now. Anyway, that was just to make the test clear with what should happen - I don't actually use ch for Firefox in my app, where I noticed the problem. Also, what do you mean that Chrome doesn't display as intended? Chrome 34 on a Mac wraps just the last 0, which I think is correct, but Firefox wraps a word earlier. Are you seeing different behavior? May 6, 2014 at 21:41
  • I am using Chrome for windows, but it does wrap the last zero only. It wasn't clear that this was what you were going for. Not sure where your problem is.
    – Sablefoste
    May 7, 2014 at 1:38
  • Firefox wraps the previous double-zeros as well, because the space after them overflows. That's not how ~any real text editors work, so it looks funky (and causes inconsistent page counts which matters a lot for my app). May 7, 2014 at 3:58

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.