What Is nbsp in HTML?

1 min read

How to Use   in HTML

In HTML, a non-breaking space is written as ‘ ’.

Ivan Ivanov

Result: Ivan Ivanov

How Does   Differ from an Ordinary Space?

  • An ordinary space allows a line break. A   does not: the browser will not break the line at that position.
  • HTML collapses two or more consecutive ordinary spaces into one. By contrast, consecutive   characters remain as specified in the HTML.

When Should You Use  ?

Examples of when to use  :

  • Between initials and a surname (‘Petrov I.I.’).
  • In numbers with spaces (‘300 000’).
  • In dates (‘4 July’).
  • Between numbers and the words or units that follow them (‘1000 devils’, ‘20000 leagues under the sea’, ‘1984 AD’).
  • Between an abbreviation and a name (‘Mr Petrov’, ‘R. Amazon’).
  • Between a number or section sign and a numeral (‘No. 1’, ‘§ 4’).
  • In software names (‘Android 11’).

When Should You Avoid  ?

Avoid using two or more consecutive   characters to add spacing for styling or positioning. This can cause display problems on small screens.

Alternatives to  

The CSS Property ‘white-space: nowrap’

As an alternative to  , use the CSS property white-space: nowrap to prevent line breaks.

This is particularly useful when you need to prevent breaks in text without spaces:

  • A phone number: 111-11-11
  • A hyphenated word: ‘sometime-or-other’

The ‘nobr’ Tag (Non-Breaking Text)

Wrap text in a ‘nobr’ tag to prevent line breaks:

  • <nobr>212-85-06</nobr>
  • <nobr>first-of-all</nobr>
Back to blog