ARCHIVED: In HTML, what is a non-breaking space?

This content has been archived, and is no longer maintained by Indiana University. Information here may no longer be accurate, and links may no longer be available or reliable.

A non-breaking space prevents line breaks from occurring at a particular point in an HTML document. To use a non-breaking space, you would use the following:

   

For example, if you wanted the words "Mr." and "Foo" to appear together even if a line break would normally separate the two words, you would use the following:

  Mr. Foo

Unlike other empty spaces in HTML documents, the effects of non-breaking spaces are cumulative. That is, while browsers weed out extra white space when rendering a page, all non-breaking spaces are rendered. They're especially useful inside <code> tags, for example:

  <code>&nbsp;</code>

These tags cause the spaces to be rendered in a monospace font rather than a proportional font, thus guaranteeing that the spaces will always appear with a fixed size.

A non-breaking space also counts as real content, which is useful to produce an empty table data cell when you have table borders turned on, for example:

  <td>&nbsp;</td>

The symbols that produce the non-breaking space (&nbsp;) form what is called a character entity. Many such character entities exist for producing unusual characters in HTML documents. For more information, see ARCHIVED: How do I use special characters on my web page?

This is document agjn in the Knowledge Base.
Last modified on 2018-01-18 12:26:13.