nonbreaking spacesPrevent awkward breaks

Your word proces­sor as­sumes that a word space marks a safe place to flow text onto a new line or page. A non­break­ing space is the same width as a word space, but it pre­vents the text from flow­ing to a new line or page. It’s like in­vis­i­ble glue be­tween the words on ei­ther side.

WordPagesHTML
nonbreaking spacecontrol (option on Mac) + shift + space baroption + shift + space bar 

Put a non­break­ing space be­fore any nu­meric or al­pha­betic ref­er­ence to pre­vent awk­ward breaks. Re­call this ex­am­ple from para­graph and sec­tion marks:

The seller can, under Business Law §
1782, offer a full refund to buyers. But ¶
49 of the contract offers another option.
wrong
The seller can, under Business Law
§ 1782, offer a full refund to buyers. But
¶ 49 of the contract offers another option.
right

In the top ex­am­ple, nor­mal word spaces come af­ter the § and ¶ sym­bols, and the nu­meric ref­er­ences in­cor­rectly ap­pear on the next line.

In the bot­tom ex­am­ple, non­break­ing spaces come af­ter the § and ¶ sym­bols. This time, the sym­bols and the nu­meric ref­er­ences stay together.

Use non­break­ing spaces af­ter other ab­bre­vi­ated ref­er­ence marks (Ex. A, Fig. 23), af­ter copy­right sym­bols (see trade­mark and copy­right sym­bols), and be­tween the dots in cer­tain el­lipses.

Nonbreaking spaces in HTML

Non­break­ing spaces can be in­serted into HTML doc­u­ments ei­ther with an es­cape code ( ) or by typ­ing a non­break­ing space char­ac­ter (us­ing what­ever key short­cut is as­signed to it in your text editor).

If you be­lieve in the prin­ci­ple that source code should be op­ti­mized for read­abil­ity—I do—then you should use the   es­cape code, as it makes the non­break­ing space vis­i­ble and explicit.

by the way
  • Why isn’t there a stan­dard key short­cut for the non­break­ing space? Beats me.

  • Un­like other white space in HTML, a se­quence of non­break­ing spaces is not col­lapsed into a sin­gle word space. So the­o­ret­i­cally, you can make larger spaces out of non­break­ing spaces. But as with any white-space char­ac­ters, this is bad pol­icy—like fix­ing a flat tire with duct tape.