What is a Non-Breaking Space?
A non-breaking space is a space what will be respected in layouts and displays by browsers and computer programs. Generally, simple spaces are treated as places where it is appropriate to place a line break, and multiple spaces may be collapsed by a browser when it displays, for convenience. With a non-breaking space, the space is held. There are a number of settings where this is appropriate and there is an HTML entity,  , used to code non-breaking spaces into a display.
The concept of the non-breaking space is a carryover from typesetting, where sentence spacing needed to be controlled to prevent awkward problems and for aesthetic reasons. With the development of electronic typesetting, people needed a way to control spaces in specific settings, and this was brought into the Internet as well. Controlling spacing and other elements when text is displayed allows people to customize the appearance 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 broken with a line break, like a formal title and name, such as “Mr. Jones,” or a measurement, like “16 cups.” Using a non-breaking space will ensure that a line break will not be inserted by a computer program or browser; if there is not enough room for it to fit on one line, it will be dropped to the next line down.
For certain formatting purposes, like poetry, non-breaking spaces can also be useful. People should be careful about using the HTML entity, as some browsers will treat a string of non-breaking 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 odd in another; forcing white space with non-breaking spaces can result in display errors.
In HTML, non-breaking spaces are sometimes used to create space between visual elements, or to hold cells in a table open. Some browsers have difficulty reading empty cells and may move the elements of a table around, causing problems with layout. Sticking a non-breaking space inside the cell will alert the browser to the fact that the cell is supposed to be displayed as empty.
Many software programs insert non-breaking spaces automatically when they are appropriate, as do some "what you see is what you get" (WYSIWYG) editors used online. These programs use known spelling and grammar conventions to insert hard spaces when it is assumed that the user does not want a line break to appear.
Discuss this Article
Post your comments