Nbsp

Updated: 03/10/2024 by Computer Hope
nbsp or non-breaking space

Alternatively called a fixed space or hard space, nbsp (non-breaking space) is used in programming and word processing to create a space in a line that cannot be broken by word wrap. With HTML (hypertext markup language),   lets you create multiple spaces that are visible on a web page and not only in the source code.

Creating a fixed space in a word processor and other programs

Use one of the keyboard shortcuts below to create a fixed or hard space in a word processor such as Microsoft Office or LibreOffice.

Microsoft Windows

Ctrl+Alt+spacebar, or Ctrl+spacebar.

Or, hold down Alt and press 0160 or 255 on the num pad.

macOS

Option+Spacebar.

Microsoft Word

Ctrl+Shift+space.

WordPerfect

Ctrl+spacebar.

LibreOffice

Ctrl+spacebar (before 3.0) or Ctrl+Shift+space (after 3.0).

Creating an nbsp in HTML

An example of how a user may insert an nbsp in HTML would be by adding the following HTML entity.

 

or

 

In the examples above, this entity allows users to create multiple spaces in a row, which cannot be produced by pressing the Spacebar. To create multiple spaces, insert additional instances of the entities mentioned above. For example, if you wanted five extra spaces in front of some text, type in five of these entities, as shown below.

Example code:

Extra spaces are needed for various reasons.

     Added five spaces before this text.

The example above generates the following on a web page, with five spaces before the second sentence.

Example output:

Extra spaces are needed for various reasons.

     Added five spaces before this text.

Tip

If you need to indent or add extra spacing to a paragraph, sentence, or another portion of your web page, we suggest using CSS (cascading style sheets) instead of multiple non-breaking spaces. Alternatively, use the <pre> tag.

Null character, Programming terms, Spacebar