This site is supported by donations to The OEIS Foundation.
Template:Nbsp
[⧼Purge⧽ Template:Nbsp]
The {{nbsp}} (no-break space, formerly known as non-breaking space) typographical template inserts no-break spaces.
Contents
Usage
To get a single no-break space:
- {{nbsp}} or {{nbsp|htm}} (default)
or
- {{nbsp|tex}}
where the parameter is taken from
- htm (default): to get the HTML+CSS Unicode character U+00A0 (no-break space), which is a no-break variant (i.e. 1/3 em @opsp@@opsp@≈@opsp@@opsp@ 0.33333em no-break space) of the ordinary space U+0020 (space, also known as SP);
- tex: to get the TeX/LaTeX ~ command, which yields a 6mu (mathematical units) no-break space, i.e. 6/18 of a quad space. (You may use this template within the {{math}} template, but not within the
<math>...</math>
element.)
To get a specified number of no-break spaces:
- {{nbsp|nonnegative integer}} or {{nbsp|nonnegative integer|htm}} (default)
or
- {{nbsp|nonnegative integer|tex}}
where the first parameter (nonnegative integer) is the number of no-break spaces wanted; and the second parameter is taken from
- htm (default): to get the HTML+CSS Unicode character U+00A0 (no-break space), which is a no-break variant (i.e. 1/3 em @opsp@@opsp@≈@opsp@@opsp@ 0.33333em no-break space) of the ordinary space U+0020 (space, also known as SP);
- tex: to get the TeX/LaTeX ~ command, which yields a 6mu (mathematical units) no-break space, i.e. 6/18 of a quad space (you may use this template within the {{math}} template, but not within the
<math>...</math>
element).
Note: It is better to use a thin space (3 mu space) (with {{thinsp}}, {{sp|thin}} or {{sp|3}}), or maybe even a hair space (1 mu space) (with {{sp|hair}} or {{sp|1}}), rather than {{nbsp}} (6 mu space, no-break) when, e.g. an ''italic'' character leans too close to the following [non-italic] character.
Examples
Examples with valid input
The code
- <span style="background: #f2f2f2;">Read on{{nbsp|0}}after 0 no-break space.</span>
yields
- Read onafter 0 no-break space.
The code
- <span style="background: #f2f2f2;">Read on{{nbsp}}after 1 no-break space.</span>
yields
- Read on after 1 no-break space.
The code
- <span style="background: #f2f2f2;">Read on{{nbsp|htm}}after 1 no-break space.</span>
yields
- Read on after 1 no-break space.
The code
- <span style="background: #f2f2f2;">Read on{{nbsp|1}}after 1 no-break space.</span>
yields
- Read on after 1 no-break space.
The code
- <span style="background: #f2f2f2;">Read on{{nbsp|4}}after 4 no-break spaces.</span>
yields
- Read on after 4 no-break spaces.
The code
{{math| \text{Read on}{{nbsp|tex}}\text{after 1 no-break space.} |$$}}
yields
The code
{{math| \text{Read on}{{nbsp|4|tex}}\text{after 4 no-break spaces.} |$$}}
yields
Examples with invalid input
The code
- <span style="background: #f2f2f2;">Read on{{nbsp|-1}}after -1 no-break space.</span>
yields
- Read on Repeat error: First argument must be a nonnegative integer after -1 no-break space.
The code
- <span style="background: #f2f2f2;">Read on{{nbsp|four}}after four no-break spaces.</span>
yields
- Read on Repeat error: First argument must be a nonnegative integer after four no-break spaces.
Code
Note: We do not use its named entity for [XHTML5] future proofing (see MediaWiki#Named character references).
<noinclude>{{Documentation}}<!-- HTML+CSS: use htm option (default) TeX/LaTeX: use tex option (you may use this template within the {{math}} template, but not within the <math>...</math> element) ~ is 6mu (mathematical units) no-break space, i.e. 6/18 of a quad space --></noinclude><includeonly>{{#switch: {{lc: {{{1|}}} }} | htm =  <!-- no-break space --> | tex = ~ | {{#switch: {{lc: {{#if: {{{2|}}} | {{{2}}} | htm }} }} | htm = {{repeat| {{#if: {{{1|}}} | {{{1}}} | 1 }} | }}<!-- no-break space --> | tex = {{repeat| {{#if: {{{1|}}} | {{{1}}} | 1 }} |~}} }} }}</includeonly>
See also
- {{sp}} (horizontal space of a chosen width, possibly negative)
- {{thinsp}} (3mu space, i.e. 3/18 of a quad space, or 1/6 em @opsp@@opsp@≈@opsp@@opsp@ 0.16667em)
- {{nbsp}} (6 mu no-break space, i.e. 6/18 of a quad space, or 1/3 em @opsp@@opsp@≈@opsp@@opsp@ 0.33333em) (formally known as: non-breaking space)
- {{indent}} (standardized indentations)
- {{nl}} (new line)