Non-breaking space ( ) in HTML
A non-breaking space is a space that a line will not break at and that does not collapse with its neighbours. Its named reference is and its code point is U+00A0.
At a glance
- Character
- (invisible, one space wide)
- Named entity
-
- Decimal reference
-  
- Hex reference
-  
- Unicode code point
- U+00A0
- Unicode name
- NO-BREAK SPACE
- In the entity reference
- Punctuation, and pinned in quick access
In detail
The character does two things, and most people only know about one of them. It prevents a line break at that position, which is the reason it exists, and it also does not collapse. HTML reduces any run of ordinary whitespace to a single space, but a run of these survives intact, which is why the character became the standard hack for indentation in the years before CSS could do the job.
That second behaviour is why it should almost never be used for spacing. Repeating it to push something across the page produces a gap that does not scale with the font size, does not respond to the viewport, and cannot be adjusted without editing the content. Padding, margin and gap all do the same job in a way that a stylesheet can change.
Where it genuinely belongs is between two things that must stay on the same line: a number and its unit, a name and its initial, a section sign and its number, a currency symbol and its amount. In those cases it is expressing a real typographic requirement that no CSS property covers, because the requirement is about the content rather than the box.
The cost is that it is not an ordinary space to anything that reads the text. A search for a phrase typed with a normal space will not match content stored with this character, a split on a space will not split there, and a trim will not remove it from the ends of a string. Any input handling that normalises whitespace has to include it explicitly.
Examples
<p>The file is 4.7 MB.</p>
<p>Contact Dr A. Sharma before Friday.</p>const raw = "New\u00A0York ";
raw.trim(); // still contains U+00A0
raw.replace(/\s+/gu, " ").trim(); // "New York"The Unicode aware whitespace class matches U+00A0. A plain ASCII space character class does not.
Things that catch people out
- A search box will not match a phrase across one of these unless your indexer normalises whitespace. Users see a page containing the words and get no result.
- Runs of them used as indentation cannot be restyled and behave badly at other font sizes. Use padding.
- Copying text out of a page brings the character with it, so a value pasted into a spreadsheet or a code editor can carry an invisible non-ASCII byte.
Try it: HTML Entity Reference
Search 152 entities across 9 categories, switch the copy format between the character, the name, the decimal form and the hex form, and copy in one click.
HTML Entity Reference
LOCAL · Browser-OnlySearchable reference of 150+ HTML entities with one-click copy in any format
152 entities across 9 categories
Commonly Used
→Arrows(13)
±Math(35)
$Currency(8)
…Punctuation(21)
©Symbols(24)
πGreek(30)
½Fractions(6)
●Geometric(7)
æLatin Special(8)
Click any entity card to copy it in your chosen format. All data is embedded in the page and works offline.
Related HTML entities
All html entities →Thin space ( ) in HTML
The thin space at U+2009, its named reference, its use as a digit group separator, and the narrow no-break space that stops a number splitting.
Zero width space (U+200B) in HTML
The zero width space at U+200B, why it is not in the entity reference tool, how it lets long strings wrap, and the trouble an invisible character causes.
Em space ( ) and en space ( ) in HTML
The em space at U+2003 and en space at U+2002, their named references, how their widths track the font size, and why CSS is usually the better tool.
Soft hyphen (­) in HTML
The soft hyphen at U+00AD, what it does that a normal hyphen cannot, why it wrecks copy and search, and when CSS hyphenation is the better answer.
Ampersand (&) in HTML
The ampersand opens every character reference, so a bare & in markup is ambiguous. What & fixes, and the query string trap that quietly eats a parameter.
Less than sign (<) in HTML
A literal < starts a tag, so text containing it has to be written <. Where the parser recovers, where it does not, and why this is the core of escaping.
Tools for this
- HTML Entity Reference Free online HTML entity reference - search and copy HTML entities with live preview
- HTML Entity Encoder Free online HTML entity encoder - encode or decode HTML entities to prevent XSS and display issues