Nbsp Character: What the Non-Breaking Space Is and When to Use It

The nbsp character is Unicode U+00A0, a space that keeps adjacent words on one line. Learn how it is encoded, how it differs from a normal space, and where it causes problems.

The nbsp character, short for non-breaking space, looks exactly like an ordinary space but behaves differently. It tells line-breaking software not to split the text at that point, so the words on either side stay together. Because it is invisible and resembles a regular space, it is a common source of confusion when text is copied, searched, compared or processed by code. This review explains what the character is, what inserting it actually changes, and when a plain space is the better choice.

The short answer: is a non-breaking space right for your use?

Use a non-breaking space when a line break between two specific items would harm reading. Typical cases are a number and its unit, an initial and a surname, a currency symbol and an amount, or a short word that should not be left dangling at the end of a line. The main benefit is controlled line wrapping that travels with the text itself rather than depending on page styling.

The decisive tradeoff is that the character is visually indistinguishable from a normal space but is a different code point. Software that compares, searches, splits or trims text may treat it differently from a regular space, which can cause failed matches, unexpected word joins or data-cleaning bugs.

Plain spaces are preferable in data fields, identifiers, file names, code, search terms, form input, spreadsheets intended for further processing, and anywhere text will be compared by machines. They are also preferable when the goal is visual spacing or indentation; repeated non-breaking spaces are a fragile substitute for proper layout, and in web pages CSS is the appropriate tool for that.

Nbsp in Unicode: code point and encodings

In Unicode, the non-breaking space is U+00A0, formally named NO-BREAK SPACE. It sits in the Latin-1 Supplement block, which is why it also exists as byte A0 in the older ISO-8859-1 and Windows-1252 encodings. The common representations are summarized below.

Unicode code point:   U+00A0  (NO-BREAK SPACE)
UTF-8 bytes:          C2 A0
UTF-16 code unit:     00A0
Latin-1 / CP1252:     A0
HTML named entity:     
HTML decimal ref:      
HTML hex ref:          
CSS escape:           \A0  (or \00A0)
JavaScript / JSON:    \u00A0
Python string:        \u00a0  or  \xa0

The UTF-8 form is worth recognizing. When UTF-8 text containing a non-breaking space is wrongly decoded as Latin-1 or Windows-1252, the two bytes C2 A0 often show up as a stray capital A with a circumflex followed by an apparent space. That pattern is a strong hint that an encoding mismatch, not the character itself, is the problem.

What inserting a non-breaking space actually changes

Replacing a regular space (U+0020) with U+00A0 is a stored character change, not a visual style. The text now contains a different code point, and that difference persists through copying, saving and transmission unless some step converts it back. On screen, most fonts draw it with the same width as a normal space, so the change is usually invisible.

Its documented behavior comes from the Unicode line breaking rules, where U+00A0 belongs to the class that glues neighboring characters together. A conforming layout engine will not break a line at that position. In HTML, browsers also do not collapse a run of non-breaking spaces into one, unlike ordinary spaces, which is why the entity has long been misused to force extra horizontal gaps.

It is worth separating this from presentation-only alternatives. In web pages, the CSS property white-space: nowrap can prevent wrapping across a span of text without changing the stored characters. That keeps the underlying text clean for copying and processing, at the cost of the behavior disappearing wherever the styling does not travel, such as plain-text exports.

How it differs from similar invisible characters

Several other Unicode characters prevent or affect line breaks. Choosing the wrong one can change width or meaning, so the distinctions matter.

Character | Code point | Width | Typical purpose
Space | U+0020 | Normal | Ordinary word separation; a line may break here
No-break space | U+00A0 | Normal space width in most fonts | Keep two items on one line
Narrow no-break space | U+202F | Narrower than a normal space | Thin non-breaking gaps, such as French punctuation spacing or digit grouping
Figure space | U+2007 | Width of a digit | Aligning numbers; also non-breaking
Word joiner | U+2060 | Zero width | Prevent a break without adding visible space
Zero-width no-break space | U+FEFF | Zero width | Now used mainly as a byte order mark; U+2060 is recommended for joining instead

Unicode also defines a compatibility decomposition for U+00A0 to a regular space. As a result, compatibility normalization (NFKC or NFKD) converts a non-breaking space into U+0020, while canonical normalization (NFC or NFD) leaves it unchanged. If a pipeline applies NFKC, any intentional non-breaking spaces will be lost.

Will it survive copying, sharing and processing?

Because the non-breaking space is a real character, it generally travels with copied text. Whether it arrives intact depends on each step: the source application, the clipboard format, and the destination. Some editors, browsers and content systems convert it to a regular space on copy or paste, while others preserve it or turn it into the HTML entity. No destination-specific tests were supplied for this article, so behavior in any named application should be confirmed with a quick check rather than assumed.

Programming languages disagree about whether it counts as whitespace, which is a frequent cause of bugs:

  • JavaScript: the regular expression class \s matches U+00A0, and String.prototype.trim removes it.
  • Python 3: str.split() with no arguments, str.strip() and the \s class in str patterns treat U+00A0 as whitespace.
  • Java: String.trim() only removes characters up to U+0020, and Character.isWhitespace deliberately returns false for U+00A0, U+2007 and U+202F, so a non-breaking space survives both trim() and strip().
  • Exact string comparison in any language: a string with U+00A0 does not equal the same string with U+0020.

For search, a user typing a normal space may or may not match text containing a non-breaking space, depending on how the search tool normalizes input. This varies by application and was not tested here, so it remains an open question for any specific search box or index.

For accessibility, a single non-breaking space between words is generally treated by assistive technology as an ordinary word gap. Problems arise mainly when many non-breaking spaces are used to fake layout, such as indentation or columns, because the spacing carries no structural meaning. No screen reader testing was available for this article, so specific behavior in a given screen reader should be verified with that product.

Finding and replacing non-breaking spaces

Since the character cannot be seen, the reliable way to confirm it is present is to inspect code points. A Unicode inspector will show U+00A0 at the position, and a hex view of UTF-8 data will show C2 A0. In code, an explicit replacement is the clearest way to produce a plain-text equivalent:

# Python
clean = text.replace("\u00a0", " ")

// JavaScript
const clean = text.replace(/\u00A0/g, " ");

// Java
String clean = text.replace('\u00A0', ' ');

If the goal is to remove every kind of no-break space, the narrow no-break space (U+202F) and figure space (U+2007) should be included in the replacement as well. Many word processors also offer a visible-formatting mode that marks non-breaking spaces with a distinct symbol, which helps when reviewing documents by hand.

Typing a non-breaking space

  • HTML: write   or   in the source.
  • Microsoft Word on Windows: Ctrl+Shift+Space.
  • macOS: Option+Space in most text fields.
  • Any environment with a character picker: search for NO-BREAK SPACE or U+00A0.

Keyboard shortcuts depend on the application and keyboard layout, so these are common defaults rather than guarantees.

Bottom line

The non-breaking space is a precise, well-defined tool: one code point, U+00A0, that prevents a line break while looking like a normal space. It is worth using for prose that will be displayed, where keeping specific items together improves readability. It is a liability in data, code, search input and machine-compared text, where its invisibility makes mismatches hard to spot. When text must move between systems, keep a plain-space version available, and verify behavior in each destination rather than relying on how it renders in one place.