Non-Breaking Space HTML entity  

  is the HTML entity for Non-Breaking Space (U+00A0). Copy the decimal   and hex   codes plus CSS, JavaScript, Python and URL escapes.

Entity
 
Also written
 
Legacy form
&nbsp (no semicolon)
Code point
U+00A0
Unicode name
NO-BREAK SPACE
Block
Latin-1 Supplement
Category
Space separator (Zs)
Since
Unicode 1.1
Defined in
HTML 4.01 and HTML5

Codes to copy

HTML named Works in HTML; in XML only & < > " ' are predefined.
HTML decimal Works in HTML and XML.
HTML hex Works in HTML and XML.
CSScontent: "\A0";In a stylesheet, for ::before and ::after.
JavaScript"\u00A0"Also valid in JSON.
Python"\u00a0"Python 3 string literal.
Python by name"\N{NO-BREAK SPACE}"Readable alternative using the Unicode name.
URL%C2%A0Percent-encoded UTF-8 bytes, for a path or query value.
UTF-8 bytesC2 A02 bytes.
UTF-1600A01 code unit, which is what JavaScript length counts.

When to use it

A space that never breaks a line, so the words on either side stay together: 10 km, Mr Smith, 9 am. Browsers also keep a run of them instead of collapsing it into one space, which is why rows of   were once used for indentation; CSS margin or padding does that job properly. In most fonts it is exactly as wide as an ordinary space.

The name dates from HTML 4, so it works in every browser and in old email clients.

Browsers also accept the legacy form &nbsp without a semicolon, for compatibility with old pages; new HTML should always end the reference with a semicolon.

It has no visible shape of its own, which is why the box above shows it with a tinted background.

More spaces and invisible characters

All spaces and invisible characters · Every HTML entity · Encode or decode text

Source: the WHATWG HTML Standard list of named character references and the Unicode Character Database (Unicode 18.0).