Non-breaking space explained

Non-breaking space
See Also:

Other types of spaces

In word processing and digital typesetting, a non-breaking space, also called NBSP, required space,[1] 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.

Behavior

Despite having layout and uses similar to those of whitespace, 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:

By contrast, words separated with ordinary spaces will reflow as the window size changes:

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:

Uses

Numbers with units

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]

Spacing punctuation in French

In French typography, non-breaking spaces are used before "high punctuation" (:, ;, ?, and !), on the interior side of guillemets (« and »), and before footnote references. In the case of ;, ?, !, and footnote references (unless enclosed by parentheses), a narrow non-breaking space is used.[6] [7]

Multi-part abbreviations in German

In German typography, it is used between multi-part abbreviations (e.g., "z.B.", "d.h.", "v.l.n.r.").[8]

Computer languages

Non-collapsing behavior

Non-breaking spaces are used 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.[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:

In contrast, the first few words of this phrase have been separated with many ordinary spaces but are displayed (rendered by the Browser engine) as single spaces:

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".

Variations

Narrow non-breaking space

is a non-breaking space that is narrower than the standard non-breaking space (U+00A0). For Mongolian, 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 the thin space (U+2009), at least with some fonts.

This text replaces spaces with narrow non-breaking spaces:

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]

In French typography, it is called French: espace 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, a footnote reference is preceded by a narrow non-breaking space[7] (unless it is enclosed by parentheses, in which case a regular non-breaking space is used).[6]

The narrow non-breaking space is used in numbers as a group separator in French (starting in Unicode CLDR 34[16]) and Venetian (starting in Unicode CLDR 44[17]). In Spanish, the Royal Spanish Academy and Association of Academies of the Spanish Language's Diccionario panhispánico de dudas prescribes a small space as the number group separator,[18] although this is not the case in Unicode's Common Locale Data Repository (CLDR).[19]

Figure space

See main article: Figure space. A figure space is a non-breaking space whose width is equal to the figure (0 - 9) characters.

Unicode

Unicode has multiple non-breaking space characters:

See also

External links

Notes and References

  1. Web site: Windows, Latin 1 . CPGID 01252 . REGISTRY, Graphic Character Sets and Code Pages . IBM . IBM . 1998 . 1995.
  2. 10.3998/3336451.0013.105. Justify Just or Just Justify. The Journal of Electronic Publishing. 13. 2010. Elyaakoubi. Mohamed. Lazrek. Azzeddine. free. 2027/spo.3336451.0013.105. free.
  3. Web site: Special Characters . The Chicago Manual of Style Online.
  4. Web site: Style guide . UK Metric Association . 21 April 2025 . 12 July 2017 . Where there is room, leave a (non-breaking) space between the number and the unit..
  5. Web site: Numbers, units and symbols . . 21 April 2025 . 25 January 2016 . Use non-breaking spaces between numbers and units (Ctrl+Shift+Space), except for percentages and temperatures (37°C, 76%)..
  6. Book: Lexique des règles typographiques . 1990 . Imprimerie nationale . 2-11-081075-0 . 25, 148–149 . 3rd . fr.
  7. Web site: Types d’espacement . Office québécois de la langue française . . 21 April 2025 . fr-CA.
  8. Web site: Zweisprachige Mikrotypografie . Solbrig . Amelie . 30 January 2008 . Hochschule für Technik, Wirtschaft und Kultur Leipzig . 10 June 2018 . 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. . de . https://web.archive.org/web/20160311073646/http://www.verlagsherstellung.de/fileadmin/fbmedien_bmp/downloads/Abschlussarbeiten/Zweisprachige_Mikrotypografie_Amelie_Solbrig_VH-02.pdf#page=58 . 2016-03-11 . 113 .
  9. .
  10. .
  11. Web site: Writing Systems and Punctuation . The Unicode Standard 7.0 . . 2014 . 2014-11-02.
  12. Web site: AMENDMENT 29: Mongolian . ISO/IEC . Information technology — Universal Multiple-Octet Coded Character Set (UCS) — Part 1: Architecture and Basic Multilingual Plane . 1999 . ISO/IEC 10646-1:1993/FDAM 29:1999(E).
  13. Book: The Unicode Standard Version 15.0 – Core Specification . September 2022 . 6.2.3 Space Characters . The Unicode Consortium . 978-1-936213-32-0 . 268.
  14. Book: The Unicode Standard Version 16.0 – Core Specification . September 10, 2024 . 6.2.3 Space Characters . The Unicode Consortium . 978-1-936213-34-4 . 327.
  15. Book: The Unicode Standard Version 16.0 – Core Specification . September 10, 2024 . 13.5.1 Mongolian: U+1800–U+18AF . The Unicode Consortium . 978-1-936213-34-4 . 651 . 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..
  16. Web site: CLDR 34 Release Note . The Unicode Consortium . 2018-10-15 . French grouping separator changed from no-break space U+00A0 to narrow no-break space U+202F..
  17. Web site: CLDR v44.0 — By-Type Chart: Numbers:Symbols . The Unicode Consortium . 2023-10-25.
  18. Book: Diccionario panhispánico de dudas . 2022-01-07 . . es . punto . Period . 2nd (provisional version) . 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.
  19. Web site: CLDR v47.0 — By-Type Chart: Numbers:Symbols . The Unicode Consortium . 2025-03-11.
  20. Web site: FAQ - UTF-8, UTF-16, UTF-32 & BOM, ”What should I do with U+FEFF in the middle of a file?“ . Unicode.org.