White Space in HTML

It is a feature of HTML that all white space is treated identically. Any sequence of white-space characters is treated as a single space.
For example, here is one space: and here are two tabs: and here are five CRLFs: but if your browser is at all conventional, they will all look the same.

So how can you increase the separation between words of text, in HTML? There are several ways. One is to use pre-formatted text, with the <PRE> </PRE> tag pair, like this.

Here is a space: here are two spaces:  and five spaces:     and finally a CRLF:
the differences are obvious.
However this has other disadvantages: the use of a fixed-width font, and the failure of long lines to arrange themselves within a small window.

Another way is to use a "non-breaking space", by typing &nbsp;. For example,
compare a group of three normal spaces: with
a non-breaking space flanked by two normal ones:   your browser should show the second group as wider. This method works well in normal circumstances, and may be recommended by HTML authors. The use of invisible graphics, on the other hand, is rarely recommended.

However there are circumstances in which the use of &nbsp; does not achieve the intended effect. One such circumstance is if you are using certain Chinese-font software. The browser detects the &nbsp;, and converts it to the character with ascii code 160(decimal). The Chinese-font software interprets the ascii-160 character as the first half of the code for a Chinese character, and replaces it and whatever character follows it by a Chinese character. This is not at all the required effect.

To see this effect, get hold of some Chinese-character software (e.g. from TwinBridge), install it, and look at this page. If you are using Netscape, set Options - Document Encoding to Traditional Chinese (Big5). This may not work. The undesirable effect which I describe seems to depend on the operating system, the browser, and possibly other things. It may be seen even without the Chinese-font software, if you are using Netscape with the Document Encoding set to Big5. I have found that it occurs on most, but not all systems; and I do not know what makes the difference.

Anyway, we want to find a way of fooling the HTML interpreter into accepting that something is not space, when it is sure to look to the viewer like space. It is for this that I recommend the use of an invisible graphic. E.G.
here are three spaces: and
here is a non-breaking space flanked by two normal spaces:   and
here is an invisible graphic flanked by two normal spaces: see?


Return to main discussion of invisible GIFs.