Non-breaking space | |
|---|---|
| U+00A0 NO-BREAK SPACE ( ,  ) | |
| See also | |
| U+202F NARROW NO-BREAK SPACE Other types of spaces |
Inword processing anddigital typesetting, anon-breaking space ( ), also calledNBSP,required space,[1]hard space, orfixed space (in mosttypefaces,[b] it is not of fixed width), is aspace character that prevents anautomatic line break at its position. In some formats, includingHTML, it also prevents consecutivewhitespace characters from collapsing into a single space. Non-breaking space characterswith other widths also exist.
Despite having layout and uses similar to those ofwhitespace, it differs in contextual behavior.[2][3]
Text-processing software generally assumes that an automatic line break may be inserted anywhere a space character occurs; a non-breaking space prevents this from happening, if it is supported by the software.
To show the effect of the non-breaking space in text, the following words have been separated with non-breaking spaces. No matter the width of the window, no line breaks are displayed:
Lorem Ipsum Dolor Sit Amet Consectetur Adipiscing Elit Sed Do Eiusmod Tempor Incididunt Ut Labore Et Dolore Magna Aliqua Ut Enim Ad Minim Veniam Quis Nostrud Exercitation Ullamco Laboris Nisi Ut Aliquip Ex Ea Commodo Consequat Duis Aute Irure Dolor In Reprehenderit In Voluptate Velit Esse Cillum Dolore Eu Fugiat Nulla Pariatur Excepteur Sint Occaecat Cupidatat Non Proident Sunt In Culpa Qui Officia Deserunt Mollit Anim Id Est Laborum
By contrast, words separated with ordinary spaces will reflow as the window size changes:
Lorem Ipsum Dolor Sit Amet Consectetur Adipiscing Elit Sed Do Eiusmod Tempor Incididunt Ut Labore Et Dolore Magna Aliqua Ut Enim Ad Minim Veniam Quis Nostrud Exercitation Ullamco Laboris Nisi Ut Aliquip Ex Ea Commodo Consequat Duis Aute Irure Dolor In Reprehenderit In Voluptate Velit Esse Cillum Dolore Eu Fugiat Nulla Pariatur Excepteur Sint Occaecat Cupidatat Non Proident Sunt In Culpa Qui Officia Deserunt Mollit Anim Id Est Laborum
In this example, most spaces are non-breaking, but every third space is an ordinary breaking space. This shows how groups of words can be prevented from being divided across lines by automatic line breaks:
Lorem Ipsum Dolor Sit Amet Consectetur Adipiscing Elit Sed Do Eiusmod Tempor Incididunt Ut Labore Et Dolore Magna Aliqua Ut Enim Ad Minim Veniam Quis Nostrud Exercitation Ullamco Laboris Nisi Ut Aliquip Ex Ea Commodo Consequat Duis Aute Irure Dolor In Reprehenderit In Voluptate Velit Esse Cillum Dolore Eu Fugiat Nulla Pariatur Excepteur Sint Occaecat Cupidatat Non Proident Sunt In Culpa Qui Officia Deserunt Mollit Anim Id Est Laborum
Text-processing software can divide expressions like "100 km" when they do not quite fit at the end of a line. A non-breaking space between "100" and "km" prevents this, and guarantees that "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. Many style guides recommend that numbers and the associated units not be split across lines; non-breaking spaces are used to ensure this.[4][5]
InFrench typography, non-breaking spaces are used before "high punctuation" (:,;,?, and!), on the interior side ofguillemets (« and»), and beforefootnotes. In the case of;,?,!, and footnotes (unless enclosed by parentheses), anarrow non-breaking space is used.[6][7]
InGerman typography, it is used between multi-part abbreviations (e.g., "z. B.", "d. h.", "v. l. n. r.").[8]
Non-breaking spaces are used inplain text file formats such asSGML,HTML,TeX andLaTeX, whose rendering engines are programmed to treat sequences ofwhitespace 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 finaltypeset result.[9][10]
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:
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
In contrast, the first few words of this phrase have been separated with many ordinary spaces but are displayed (rendered by theBrowser engine) as single spaces:
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
In programming languages or in software analysis languages (such asSAS orR) 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".
U+202F NARROW NO-BREAK SPACE (NNBSP) is a non-breaking space that is narrower than the standard non-breaking space (U+00A0). ForMongolian, its is usually one third the width of a normal space;[11] in other contexts, its width is about 70% of the normal space, but may resemble that of thethin space (U+2009), at least with some fonts.[citation needed]
This text replaces spaces with narrow non-breaking spaces:
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
Narrow non-breaking space was introduced in 1999 in Unicode 3.0 for Mongolian,[12] to separate a suffix from the word stem without indicating a word boundary. It also triggers special shaping of those suffixes.[13] Starting in Unicode 16.0, it is no longer recommended for this purpose, with the Mongolian vowel separator (U+180E) taking on this function.[14][15]
InFrench typography, it is calledespace fine insécable[14] and is used before;,?, and! (with the exception of: before which a regular non-breaking space is used).[6][7] Additionally, footnotes are preceded by a narrow non-breaking space[7] (unless they are enclosed by parentheses, in which case a regular non-breaking space is used).[6]
The narrow non-breaking space is used in numbers as agroup separator in French (starting in Unicode CLDR 34[16]) andVenetian (starting in Unicode CLDR 44[17]). In Spanish, theRoyal Spanish Academy andAssociation of Academies of the Spanish Language'sDiccionario panhispánico de dudas prescribes a small space as the number group separator,[18] although this is not the case in Unicode'sCommon Locale Data Repository (CLDR).[19]
A figure space is a non-breaking space whose width is equal to the figure (0–9) characters.
Unicode has multiple non-breaking space characters:
Where there is room, leave a (non-breaking) space between the number and the unit.
Use non-breaking spaces between numbers and units (Ctrl+Shift+Space), except for percentages and temperatures (37°C, 76%).
Alle Abkürzungen mit Binnenpunkten werden im Deutschen mit einem gFL [geschütztes flexibles Leerzeichen] spationiert. [...] Die englische Schreibweise sieht keine Abstände zwischen einzelnen Buchstaben vor. Nach einem Binnenpunkt folgt demnach ohne gFL sofort der nächste Buchstabe.
Prior to Unicode Version 16.0, U+202F NARROW NO-BREAK SPACE (NNBSP) was used to represent this small whitespace; it retains its Script_Extensions value of "Mong" to facilitate backward compatibility. However, its role has been taken over by U+180E MONGOLIAN VOWEL SEPARATOR (MVS), which not only prevents word breaking and line breaking, but also triggers special shaping for the following separated suffix.
French grouping separator changed from no-break space U+00A0 to narrow no-break space U+202F.
Para facilitar la lectura de los números cuya parte entera conste de más de cuatro cifras, se recomienda escribirlos separando con un pequeño espacio los grupos de tres dígitos, contados de derecha a izquierda