What Does Mean in HTML? The Non-Breaking Space Explained

is the HTML entity for a non-breaking space. It produces the character U+00A0 (decimal 160), which is not the same as a regular space, U+0020 (decimal 32). It differs in two ways: the browser never breaks a line at a U+00A0, and it does not collapse several in a row into one, the way it does with regular spaces.
The two look the same on screen, but code treats them as different characters, and that is where most bugs come from, especially in tests. The full list of entities is in the HTML entities reference, and codes 32 and 160 also appear in the ASCII table.
When to use
Use it when two parts of a text must stay on the same line:
- a number and its unit:
10 km,5 kg; - a currency and its amount:
R$ 10.00; - a title and a name:
Dr. Smith; - a month and a day:
November 22; - a short word at the end of a paragraph, so it does not sit alone on the last line.
<p>The trip is 10 km long and costs R$ 10.00.</p>
If the screen width forces a line break, it happens before "10" or after "km", never between them.
When not to use it
For layout spacing, if you want space between elements, use margin, padding, or gap. A row of to indent text changes with the font, is not read well by screen readers, and is hard to maintain.
To stop a whole run of text from wrapping, CSS works better:
.price {
white-space: nowrap;
}
is for the space between two words, not for a block.
The problem that shows up in tests
Intl.NumberFormat in pt-BR puts a U+00A0 between the currency symbol and the number:
const price = new Intl.NumberFormat("pt-BR", {
style: "currency",
currency: "BRL"
}).format(10);
console.log(price); // "R$ 10,00"
console.log(price === "R$ 10,00"); // false
console.log(price === "R$ 10,00"); // true
The text you typed in the test has a regular space. What Intl returns has a U+00A0. On screen they look identical, and the failure message shows the expected and received values as "equal". In French the thousands separator is another similar character, U+202F (narrow non-breaking space), so 1 234 567,5 formatted with fr-FR carries those characters.
There are two ways to fix it. One is to build the expected value with the right character, as above. The other is to normalize before comparing:
const normalize = (text) => text.replace(/[ ]/g, " ");
expect(normalize(price)).toBe("R$ 10,00");
UI tests hit the same wall: getByText("R$ 10,00") does not find the element if the page text has a U+00A0. Two details help when debugging. String.prototype.trim() and the \s in JavaScript regular expressions both treat U+00A0 as whitespace, so " ".trim() returns an empty string. The === operator does not make that equivalence.
How to write the character in each place
| Where | How to write it |
|---|---|
| HTML | ,  , or   |
| JavaScript | " " or "\xa0" |
| CSS | content: "\a0" |
| JSON | " " |
In HTML, all three forms give the same result. is the only one with a name, defined in the WHATWG list of named character references. For other characters that cause errors in translation files, see also how to add special characters on i18n.
showing up as text
If a person sees the text on the page instead of a space, the HTML was escaped twice. The & became &, and the browser shows the result literally: &nbsp; renders as the text .
This happens when an email, a CMS, or an API stores HTML that is already escaped and another layer escapes it again. The same goes for " and & showing up raw. The fix is to find the layer that escapes the second time and remove one of the two. Replacing &nbsp; with by hand only hides the problem.
Other spaces
| Entity or code | Character | What it does |
|---|---|---|
| U+00A0 | non-breaking space, one space wide |
  | U+2002 | space as wide as an "n" |
  | U+2003 | space as wide as an "m" |
  | U+2009 | thin space |
| (no name) | U+202F | narrow non-breaking space |
​ | U+200B | zero-width space |
The other codes, such as &, <, >, and ", are in the HTML entities reference. The MDN Character reference glossary entry explains the concept.


