Unicode Space Characters: Tab, Thin, Hair, Em and En Space
The space bar types one kind of space, but Unicode defines many more: wide ones, thin ones, ones that refuse to break across lines, and one that is as wide as a Chinese character. They all look like a gap, and software treats each as a different character. This guide lists them with their code points, widths and uses, and shows how to find them and turn them back into ordinary spaces.
Space characters compared
| Code | Name | Width | Typical use |
|---|---|---|---|
U+0020 | Space | Set by the font; stretches in justified text | The normal gap between words |
U+0009 | Tab (character tabulation) | Not fixed; jumps to the next tab stop | Indentation, columns, tab-separated data |
U+00A0 | No-break space (NBSP) | Same as a space | Keeps two words on one line |
U+2002 | En space | Half an em | A fixed, wider gap |
U+2003 | Em space | One em, the size of the type | Paragraph indents, wide separation |
U+2004 | Three-per-em space | A third of an em | Fine typesetting |
U+2005 | Four-per-em space | A quarter of an em | Fine typesetting |
U+2006 | Six-per-em space | A sixth of an em | Fine typesetting |
U+2007 | Figure space | The width of a digit; does not break | Lining up numbers in columns |
U+2008 | Punctuation space | The width of a full stop | Lining up numbers with punctuation |
U+2009 | Thin space | About a fifth of an em | Between a number and its unit, inside nested quotes |
U+200A | Hair space | Thinner than a thin space | A sliver of room around dashes and symbols |
U+202F | Narrow no-break space | Narrow; does not break | Digit grouping, French punctuation |
U+205F | Medium mathematical space | Four eighteenths of an em | Mathematical formulas |
U+3000 | Ideographic space | The width of one Chinese or Japanese character | East Asian text |
An em is a unit equal to the current type size, so in 16-pixel text an em space is 16 pixels wide. The widths in the table are the nominal ones. Fonts are free to differ, and in a monospaced font most of these spaces come out the same width.
The zero-width space, U+200B, is missing from the table on purpose. Despite its name, Unicode classes it as a format character and not as a space. It is covered in our zero-width space guide.
Whitespace characters as software sees them
Unicode has a category called space separators, and it holds 17 characters: the normal space, the no-break space, the eleven characters from U+2000 to U+200A, the narrow no-break space, the medium mathematical space, the ideographic space and the Ogham space mark U+1680. The tab is not among them. It is a control character, in the same group as the line feed and the carriage return.
The wider property that programmers call white space covers those 17 plus the tab, the line-ending controls and the line and paragraph separators, 25 characters in all. This is roughly the set that \s matches in a regular expression in JavaScript or Python, and the set that a trim function removes from the ends of a string. So a trim usually does remove a no-break space or an ideographic space from the ends. What it does not do is turn one in the middle of a string into a normal space, and that is where the problems start.
The spaces you are most likely to meet
Tab
The tab character does not have a width. It tells the display to move to the next tab stop, which is every eight columns in most terminals and whatever you set in an editor or a word processor. That is why a tab-indented file looks different from one program to the next.
Tabs carry meaning in several file formats. Tab-separated files use them between fields. A Makefile requires a tab at the start of each command line. YAML goes the other way and forbids tabs for indentation, and Python refuses a file that mixes tabs and spaces in a way that makes the indentation ambiguous. In HTML a tab is collapsed like any other white space unless the text is preformatted.
Thin space and hair space
These are the typographer's fine adjustments. A thin space is used between a number and its unit, between the thousands groups of a long number, and between a single and a double quote mark that would otherwise touch. The hair space is thinner still and is mostly used to give an em dash or a symbol a little air. In HTML they are   and  .
Em space and en space
Both are fixed-width gaps that do not stretch when a line is justified. The em space is the traditional paragraph indent. Because browsers collapse a run of ordinary spaces into one, people also use   and   in HTML when they want a wider gap that survives.
Narrow no-break space
This one reaches ordinary data more often than you would expect, because software inserts it when formatting numbers. Ask a current browser to format a number for French and it groups the digits with U+202F:
(1234567.89).toLocaleString("fr-FR") // "1 234 567,89" with U+202F between groups
(1234567.89).toLocaleString("sv-SE") // the same pattern with U+00A0
A figure formatted this way looks perfect and then fails to parse as a number, or fails to match the same figure typed with normal spaces. The exact character depends on the language and on the version of the browser's language data.
Ideographic space
Chinese and Japanese text is set in a grid of square characters, and the ideographic space fills exactly one square. Japanese input methods type it when the space bar is pressed in full-width mode. It regularly turns up in names, addresses and search queries entered on those keyboards, where it prevents a match with the same text typed using normal spaces.
Figure space
A figure space is as wide as a digit in fonts whose digits share one width. It lets you pad a column of numbers so the digits line up, and it does not allow a line break.
HTML entities for spaces
| Space | Entity | Numeric form |
|---|---|---|
| No-break space | |   |
| En space |   |   |
| Em space |   |   |
| Figure space |   |   |
| Thin space |   |   |
| Hair space |   |   |
| Narrow no-break space | none in common use |   |
| Ideographic space | none |   |
| Tab | 	 | 	 |
Why special spaces cause trouble
- Search and comparison fail. Two phrases that look the same are different strings when one has a thin space where the other has a normal one.
- Splitting goes wrong. Code that splits a sentence on the normal space character treats two words joined by a no-break space as one word.
- Numbers will not parse. A figure with a narrow no-break space between its digit groups is text to a spreadsheet.
- Layouts shift. A fixed-width space does not stretch in justified text and a no-break space will not wrap, so lines break in odd places.
How to find and replace them
Paste the text into the AI Text Cleaner. Every special space is named in the list of characters found, with its code and a count. With Replace unusual spaces switched on, which is the default, the no-break space, the Ogham space mark, everything from U+2000 to U+200A, the narrow no-break space, the medium mathematical space and the ideographic space each become one normal space.
Tabs are handled separately. A single tab is kept as it is. The option Fix extra spaces collapses any run of two or more spaces or tabs inside a line into one space, and it removes spaces and tabs at the ends of lines. Switch that option off before cleaning tab-separated data: two tabs in a row mark an empty field there, and collapsing them would shift the columns.
In code, a regular expression does the same replacement. In JavaScript:
const clean = text.replace(/[ - ]/g, " ");
In a spreadsheet, replace one kind at a time with its decimal code, for example the narrow no-break space:
=SUBSTITUTE(A1, UNICHAR(8239), " ")
Quick answers
How many space characters does Unicode have? Seventeen in the space separator category. Counting the tab, the line-ending characters and the separators, 25 characters have the white space property.
Is a tab the same as several spaces? No. A tab is one character, U+0009, and its width on screen depends on the tab stops of the program showing it.
What is the thinnest visible space? The hair space, U+200A. The zero-width space is thinner in the sense that it has no width at all, but it is not classed as a space.