Non-breaking spaces are used to prevent line breaks in specific settings, such as formal titles or measures. They can also be useful for formatting poetry and keeping cells in tables open. However, using them can cause display errors and some browsers may treat solid spaces as a single space. Some software programs automatically insert non-breaking spaces when appropriate.
A non-breaking space is a space that will be respected in layouts and displays by browsers and computer programs. Typically, plain spaces are treated as where a line break is appropriate, and multiple spaces can be collapsed by a browser when displayed, for convenience. With an indestructible space, space is held. There are a number of settings where this is appropriate and there is an HTML entity, , used to encode non-breaking spaces in a display.
The concept of a non-breaking space is a carryover of composition, where the spacing of sentences had to be controlled to avoid embarrassing problems and for aesthetic reasons. With the development of electronic typesetting, people needed a way to control spaces in specific environments, and this has also been brought to the internet. Controlling spacing and other elements when text is displayed allows people to customize the look of a website and the information presented.
In a simple example of a setting where people might want to use a non-breaking space, there are some things users might not want to see interrupted with a line break, such as a formal title and name, such as “Mr. Jones” or a measure, such as “16 cups”. Using a non-breaking space will ensure that a line break is not inserted by a computer program or browser; if there isn’t enough room to fit on one row, it will be dropped onto the next row.
For some formatting purposes, such as poetry, non-breaking spaces can also be useful. People should be careful using the HTML entity, as some browsers will treat a string of solid spaces as a single space and may change the formatting. Browsers also display content differently, and content that looks acceptable in one browser may look weird in another; forcing white space with non-breaking spaces can cause display errors.
In HTML, non-breaking spaces are sometimes used to create space between visual elements or to keep cells in a table open. Some browsers have trouble reading empty cells and may move table elements around, causing layout issues. Sticking a non-breaking space inside the cell will warn the browser that the cell should display as blank.
Many software programs automatically insert non-breaking spaces when appropriate, as do some “what you see is what you get” (WYSIWYG) editors used online. These programs use well-known spelling and grammatical conventions to insert hard spaces when it assumes the user does not want a line break to appear.
Protect your devices with Threat Protection by NordVPN