Non-breaking space
Template:Short description Template:Redirect-distinguish Template:Infobox punctuation mark
In word processing and digital typesetting, a non-breaking space (Template:Char), also called NBSP, required space,<ref>Template:Cite web</ref> hard space, or fixed space (in most typefaces, it is not of fixed width), 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.<ref>Template:Cite journal</ref><ref>Template:Cite web</ref>
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 (provided the software recognizes the character).
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.<ref>Template:Cite web</ref><ref>Template:Cite web</ref>
In French typography, non-breaking spaces are used before "high punctuation" (:, ;, ?, and !), on the interior side of guillemets (« and »), and before footnotes. In the case of ;, ?, !, and footnotes (unless enclosed by parentheses), it is specifically the narrow non-breaking space that is used.<ref name="IN Group">Template:Cite book</ref><ref name="Quebec">Template:Cite web</ref>
In German typography, it is used between multi-part abbreviations (e.g., "z.Template:NnbspB.", "d.Template:Nnbsph.", "v.Template:Nnbspl.Template:Nnbspn.Template:Nnbspr.").<ref>Template:Cite web</ref>
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 (space, newline, tab, form feed, etc.) as if they were a single character (but this behavior can be overridden). 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.<ref>Template:Citation.</ref><ref>Template:Citation.</ref>
Non-void or non-missing behavior
In programming languages or in software analysis languages (such as SAS or R) 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". The non-breaking space code for R is \u00A0.
Variations
Narrow non-breaking space
Template:Unichar is another non-breaking space, but with a smaller width than the standard non-breaking space (U+00A0). When used with Mongolian, its width is usually one third of the normal space;<ref>Template:Cite web</ref> in other contexts, its width is about 70% of the normal space, but may resemble that of the thin space (U+2009), at least with some fonts.Template:Citation needed
It was introduced in 1999 in Unicode 3.0 for Mongolian,<ref>Template:Cite web</ref> to separate a suffix from the word stem without indicating a word boundary. It also triggers special shaping of those suffixes.<ref name="Unicode Standard 15 - NNBSP">Template:Cite book</ref> Starting in Unicode 16.0, it is no longer recommended for this purpose, with the Mongolian vowel separator (U+180E) being recommended for this purpose instead.<ref name="Unicode Standard 16 - NNBSP">Template:Cite book</ref><ref name="Unicode Standard 16 - Mongolian">Template:Cite book</ref>
In French typography, it is called Template:Lang<ref name="Unicode Standard 16 - NNBSP"/> and is used before :, ;, ?, and !.<ref name="IN Group"/><ref name="Quebec"/> Additionally, footnotes are preceded by a narrow non-breaking space<ref name="Quebec"/> (unless they are enclosed by parentheses, in which case a regular non-breaking space is used).<ref name="IN Group"/>
The narrow non-breaking space is used in numbers as a group separator in French (starting in Unicode CLDR 34<ref>Template:Cite web</ref>) and Venetian (starting in Unicode CLDR 44<ref>Template:Cite web</ref>). 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,<ref>Template:Cite book</ref> although this is not the case in Unicode's Common Locale Data Repository (CLDR).<ref>Template:Cite web</ref>
Other variations
Other non-breaking variants defined in Unicode.
- Template:Unichar
- Produces a space equal to the figure (0–9) characters.
- Template:UnicharTemplate:Anchor
- Encoded in Unicode since version 3.2. The word joiner does not produce any space and prohibits a line break at its position.
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: Template:Quote
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: Template:Quote
In contrast, the following words are separated with ordinary spaces:
Here, they are separated with narrow non-breaking spaces, to show the width of those:
Unicode
See also
- Hyphens in computing, for information about hard and non-breaking hyphens
- List of XML and HTML character entity references
- Template:Annotated link
- Template:Annotated link
- Template:Annotated link
- Template:Annotated link
- Template:Section link, for applications
- Template:Annotated link, a non-spacing break
- Template:Annotated link
- Template:Annotated link
- Template:Section link