Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> The HTML rendering engine in your browser actually consolidates each block of white space into a single visible space character.

I don't believe that's true when the browser decides to break the line between the two spaces -- see: http://i.imgur.com/MksV7.png (which I took from http://www.jeanhsu.com/?p=229)

So I guess you could argue that putting two spaces in HTML is strictly a negative: it does nothing, except when it makes things look worse. Even that being as it is, I'll never stop putting two spaces between sentences.



There's something kooky going on with that page. I think the CMS used for that site must be substituting one type of space character with another in Unicode, or something like that, so that the browser does not "know" how to collapse the two whitespace characters into a single whitespace character.

When I copy the two whitespace characters between sentences there into separate text files that contain nothing but those whitespace characters, then `diff a.txt b.txt`, the result is that they differ, so there is definitely some difference between the two types of whitespace characters used between sentences.

I've written a text formatting tool designed to preserve multiple whitespace instances on the Web. It used ` ` for the first of every pair of standard single space characters. Apparently, this CMS is doing something similar, but even tricker because it doesn't show up in the source as an HTML entity, and perhaps less well thought-out because for some reason the nonbreaking version space character used is the second of the two (which results in weird ghost-spaces at the beginnings of lines sometimes, as you discovered).


Indeed, performing a hex dump, the second space seems to have been replaced with 0xc2 0xa0, which is UTF-8 for:

U+00A0 NO-BREAK SPACE character

Which is the same as HTML entity  


Thanks for taking it a step further. I was to lazy to go that extra mile.

Well . . . several keystrokes, anyway, plus a Google lookup.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: