What is &nbsp in HTML?

In HTML, some characters are reserved, and in order to display such characters, we use character entities.

A character entity looks as follows:

&name_of_entity  // 1
// or
&#number_of_entity  // 2
  1. The first example uses entity names to display the reserved character.
  2. The second example uses entity numbers to display the character.

The &nbsp entity

  • &nbsp is a character entity that denotes a non-breaking or fixed space.
  • &nbsp is used to create a space that will not break into a new line by word wrap.
  • &nbsp is approximately the same as a regular space.

Syntax

<p>&nbsb;</p>
// or
<p>&#160;</p>

Code

Explanation

&nbsp; allows us to create multiple spaces in a row, something that we cannot do by using multiple spacebars in a row.

To create multiple spaces, add &nbsp; each time a space is required.