Non-breaking space


In word processing and digital typesetting, a non-breaking space, also called NBSP, required space, hard space, or fixed space, is a space character that prevents an automatic line break at its position. In some formats, including HTML, it also prevents consecutive whitespace characters from collapsing into a single space. Non-breaking space characters [|with other widths] also exist.

Uses

Despite having layout and uses similar to those of whitespace, it differs in contextual behavior.

Non-breaking behavior

Text-processing software typically assumes that an automatic line break may be inserted anywhere a space character occurs; a non-breaking space prevents this from happening.
For example, if the text "100 km" will not quite fit at the end of a line, the software may break the line between "100" and "km". Using a non-breaking space between "100" and "km" will prevent this behaviour. This guarantees that the text "100 km" will not be broken—if it does not fit at the end of a line, it is moved in its entirety to the next line. For this reason, many style guides recommend using a non-breaking space between numbers and their associated units.
In French typography, non-breaking spaces are used before "high punctuation", on the interior side of guillemets, and before footnotes. In the case of ;, ?, !, and footnotes, it is specifically the narrow non-breaking space that is used.
In German typography, it is used between multi-part abbreviations.

Non-collapsing behavior

A second common application of non-breaking spaces is in plain text file formats such as SGML, HTML, TeX and LaTeX, whose rendering engines are programmed to treat sequences of whitespace characters as if they were a single character. Such "collapsing" of whitespace allows the author to neatly arrange the source text using line breaks, indentation and other forms of spacing without affecting the final typeset result.

Non-void or non-missing behavior

In programming languages or in software analysis languages non-breaking spaces can be useful to fill character-type variables with spaces that are not to be considered insignificant. In general, a string filled with spaces can be interpreted as an empty string or a string of missing data. Replacing ordinary spaces with non-breaking spaces helps resolving the ambiguity between "space", "void" and "missing".

Variations

Narrow non-breaking space

is another non-breaking space, but with a smaller width than the standard non-breaking space. When used with Mongolian, its width is usually one third of the normal space; in other contexts, its width is about 70% of the normal space, but may resemble that of the thin space, at least with some fonts.
It was introduced in 1999 in Unicode 3.0 for Mongolian, to separate a suffix from the word stem without indicating a word boundary. It also triggers special shaping of those suffixes. Starting in Unicode 16.0, it is no longer recommended for this purpose, with the Mongolian vowel separator being recommended for this purpose instead.
In French typography, it is called espace fine insécable and is used before ;, ?, and !. Additionally, footnotes are preceded by a narrow non-breaking space.
The narrow non-breaking space is used in numbers as a group separator in French and Venetian. In Spanish, the Royal Spanish Academy and Association of Academies of the Spanish Language's Diccionario panhispánico de dudas prescribes the use of a small space as the number group separator, although this is not the case in Unicode's Common Locale Data Repository.

Other variations

Other non-breaking variants defined in Unicode.

Example

On browsers, resizing the window will demonstrate the effect of non-breaking spaces on the texts below.
To show the non-breaking effect of the non-breaking space, the following words have been separated with non-breaking spaces:
To show the non-collapsing behavior of the non-breaking space, the following words have been separated with an increasing number of non-breaking spaces:
In contrast, the first few words of this phrase have been separated with many ordinary spaces but are displayed as single spaces:
Here, they are separated with narrow non-breaking spaces, to show the width of those:

Unicode

*