Help:Line-break handling
This help page is a how-to guide. It details processes or procedures of some aspect(s) of Wikipedia's norms and practices. It is not one of Wikipedia's policies or guidelines, and may reflect varying levels of consensus and vetting. |
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
Newlines
There are several ways to force line breaks and paragraph breaks in the text. The simplest method is by inserting newlines; for example:
Markup | Renders asLua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value). |
---|---|
<br /> or <br>
The <br />
or <br>
tags are used for a single forced line break. For content that is semantically a list, such as in infoboxes, actual list markup is preferred. See § Lists below.
Markup | Renders asLua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value). |
---|---|
The MediaWiki software converts valid forms like <br>
, <br/>
, and <br >
to <br />
. Additionally, it converts the invalid form </br>
to <br />
as well. The invalid forms < br>
and </ br>
are not converted; therefore they will not create line breaks and must be avoided.
While valid forms without the /
(such as <br>
or <br >
) will work properly in the rendered page, the uncommon form <br >
can break several of the available syntax highlighters for wiki code in the editing view (mis-highlighting all text in the page after the occurrence of that tag), and so should be avoided. As of April 2019,[update] the rather common form <br>
also causes this incorrect display in some of them, and is thus better avoided for the time being.
Please correct invalid occurrences – such as </br>
, < br>
, or </ br>
– to <br />
as you encounter them, though preferably as a part of a more substantive edit.
<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 <blockquote>
. For example:
Markup | Renders asLua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value). |
---|---|
Lists
Numbered and bulleted lists are created using standard wiki markup. 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:
Markup | Renders asLua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value). |
---|---|
Formulas
To display formulas with <math>
on their own line, Wikipedia:Manual of Style/Mathematics#Using LaTeX markup recommends <math display=block>
.
Preventing and controlling word wraps
![]() | This section in a nutshell: To prevent word wraps use in place of each space, or ‑ in place of a hyphen. For more complex cases, see below. |
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.
Non-breaking space
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:
Markup | Renders asLua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value). |
---|---|
The non-breaking space works within links exactly like a regular space. Thus you can link to [[J. R. R. Tolkien]]
directly and it will render as J. R. R. Tolkien. The initials will not be separated across a line break.
However,
renders the source text harder to read and edit. Avoid using it unless it is really necessary to avoid a line break.
Non-breaking hyphen
Browsers may break words at hyphens. A non-breaking hyphen ‑
may be used to prevent this occurring, as in:
As seen on page C‑2 of the newspaper.
This code generates "page C‑2" just like the plain code "page C-2
", but prevents a line break at the hyphen.
However, like
, the use of ‑
instead of "-
" renders the source text harder to read and edit. Don't use it unless it is really necessary to avoid a line break.
Inline blocks
The templates {{Inline block}} and {{Avoid wrap}} avoid breaks, but allow them if there is not enough space. {{awrap}} is a shorthand of the latter.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt. Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt. Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium.
Both put the content in <span style="display:inline-block;">
. The latter also adds the CSS class "avoidwrap".
{{nowrap}}
The {{nowrap}} template is less flexible and will prevent breaks even when the line is too long for the window, forcing the user to scroll:
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt. Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium.
It is good for short text sections like "10 kg (22 lb)", which should always stay together.
This could also be achieved with the non-breaking space:
Lots of text 10 kg (22 lb) more text.
But this makes the source text hard to read. The template is recommended instead:
Lots of text {{nowrap|10 kg (22 lb)}} more text.
It may render like this | or like this | or like this. | But not like this. |
Lots of text 10 kg (22 lb) more text. |
Lots of text 10 kg (22 lb) |
Lots of text |
Lots of text 10 kg (22 |
(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:
{{nowrap begin}}2 + 2 = 4{{nowrap end}} and {{nowrap begin}}|2| < 3{{nowrap end}}
It may render like this:
- 2 + 2 = 4 and
- |2| < 3
But it will not render like this:
- 2 + 2 = 4 and |2|
- < 3
<wbr /> and soft hyphens
<wbr />
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.
Markup | Now is the time to become a power editor, by learning Hyper<wbr />Text Markup Language... |
---|---|
Renders as | It may render like this:
Or it may render like this (in a narrow browser window):
|
Note that <wbr />
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 <wbr />
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:
Markup | Renders asLua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value). |
---|---|
Markup | Renders asLua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value).Lua error in Module:Item at line 23: attempt to call method 'gfind' (a nil value). |
---|---|
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.
See also
Lua error in Module:Navbox at line 485: attempt to call local 'gfind' (a nil value).