You’re now familiar with the essential alphabetic, numeric, and symbol characters. We turn to the frequently overlooked
Why are they overlooked? For one thing, they’re invisible. As you learn to use white-space characters, you’ll find it helpful to make them visible. That way, you can verify that you’re typing them correctly and that they’re having the intended effect. Later, you’ll find it useful to see them while diagnosing formatting problems.
There are six important white-space characters: the word space, the nonbreaking space, the tab, the hard line break, the carriage return, and the hard page break. Each white-space character has a distinct function. Use the right tool for the job.
Control means you get the intended result with the fewest keystrokes. Suppose you need a paragraph to start at the top of the next page. What to do? If you use a hard page break rather than a sequence of carriage returns, you can get the job done with one keystroke.
Predictability means that as you edit and reformat, you’ll get consistent results. When you approximate a hard page break with carriage returns, your text will eventually reflow, and you’ll get a large gap where you intended a page break. Then you’ll have a new problem to diagnose and fix. But a hard page break will always do the right thing.
The time you invest in learning the white-space characters will be paid back in layouts that snap together faster and require less fiddling.
A word processor aims to simulate a printed layout, so each white-space character has a visible effect. An HTML document, by contrast, is a series of formatting tags. So white space is handled more like it would be in a programming language: except for nonbreaking spaces, any sequence of white space in HTML is collapsed to a single word space when the document is rendered in a browser. To achieve visible effects with white space, you need to use explicit HTML formatting tags.