Omniversalis:Line-break handling

This page explains different methods for creating, controlling and preventing line breaks and word wraps in Wikipedia articles and pages.

When a paragraph or line of text is too long to fit on one line, web browsers, like many other programs, automatically wrap the text to the next line. Web browsers usually insert the word wraps where there are spaces in the text.

Causing line breaks
There are several ways to force line breaks and paragraph breaks in the text. The simplest method is by inserting newlines; for example:

&lt;br>
The or  tag is used for a single forced line break. This can for instance be useful in a parameter of an infobox template, since tighter line spacing than paragraph breaks are often preferred inside boxes.

(For content that is semantically a list, such as in infoboxes, actual list markup is preferred. See below.)

The MediaWiki software converts valid forms like, and  to. Additionally, HTML Tidy – which is slated for removal – converts the invalid form  to. These conversions do not occur on a number of MediaWiki interface pages, and can cause invalid HTML and problems rendering the page when used there.

Until Tidy is removed, the forms, and  are equivalent. After Tidy's removal, only can be guaranteed to display correctly. Editors should therefore use.

&lt;poem>
The poem extension adds HTML-like tags to maintain newlines and spaces. This is useful for longer blocks of text such as poems, lyrics, mottoes, oaths and the like. These tags may be used inside other tags such as. For example:

Lists
Numbered and bulleted lists are created using standard wikimarkup. In cases where a plain list without number or bullet is desired, such as in an infobox, many editors will simply create a list using breaks. This method does not apply the semantics of a list, and for those using screen readers it will not sound like a list. For these cases, plainlist and unbulleted list both use list markup without numbers or bullets:

Preventing and controlling word wraps
There are several ways to prevent word wraps (line wraps) from occurring in unwanted places. This is an overview of when to use which method.

&amp;nbsp;
The HTML entity  is a non-breaking, or hard, space. It renders like a normal space " ", but prevents a line wrap from occurring, like this:

The nonbreaking space works within links exactly like a regular space. Thus you can link to  directly and it will render as J. R. R. Tolkien. The initials will not be separated across a line break.

&amp;#8209;
Similarly, words or phrases containing hyphens normally line wrap where necessary. A non-breaking hyphen may be used to prevent this occurring, as in:

As seen in section 1&amp;#8209;2 of the paper.

Thus, line wrapping that breaks the section identifier 1‑2 is prevented.

The nowrap template prevents line wraps in text and links containing spaces. Consider a more complex case like "10 kg (22 lb)". It can be coded like this:

Lots of text 10&amp;nbsp;kg&amp;nbsp;(22&amp;nbsp;lb) more text.

But that is slightly awkward. So in such cases it is instead recommended to use the nowrap template. Like this:

Lots of text 10 kg (22 lb) more text.

It may render like this:
 * Lots of text 10 kg (22 lb)
 * more text.

Or like this:
 * Lots of text
 * 10 kg (22 lb) more text.

But it will not render like this:
 * Lots of text 10 kg (22
 * lb) more text.

(For the specific case of unit conversions, see convert.)

In some cases nowrap doesn't work so well. For instance, when you want to prevent wraps in longer or more complex text, then it might be hard to see where the nowrap ends. Additionally, the MediaWiki template mechanisms interpret characters such as equal signs " " and pipes " " in template parameters as special characters, and thus they cause problems. In these cases, it is instead recommended to use nowrap begin + nowrap end, like this:

2 + 2 = 4 and
 * 2| < 3

It may render like this:
 * 2 + 2 = 4 and
 * 2| < 3

But it will not render like this:
 * 2 + 2 = 4 and |2|
 * < 3

&lt;wbr /> and soft hyphens
is a word break opportunity; that is, it specifies where it would be OK to add a line-break where a word is too long, or it is perceived that the browser will break a line at the wrong place.

Note that will not work inside nowrap.

In many cases breaking up a word with a space would be inappropriate. Soft hyphens create a word break opportunity, but will add a hyphen rather than a space. The code  is employed in the same manner as  as seen in the examples above.

Use of soft hyphens should be limited to special cases, usually involving very long words or narrow spaces (such as captions in infoboxes or other tight page layouts, or column labels in narrow tables). Widespread use of soft hyphens is strongly discouraged, because it makes the wikitext very difficult to read and to edit. For example:

Wrap between (linked) list items
In lists of links such as inside infoboxes and navboxes, use the CSS class hlist (perhaps via the template flatlist) to format lists.

For occasional cases where you need to delineate two pieces of text outside of a list, you can use the templates or  which contain a   before the dot, thus handling some of the wrapping problems.