|
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. Here is a code example: A single newline in the code does not cause a visible line break. But the paragraph is word wrapped where necessary. But an empty line in the code causes a paragraph break. And two empty lines in the code cause an extra wide paragraph break. And this line of text <br> will break in the middle. It renders like this:
The 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. These examples use the templates {{·}}, {{nowrap}}, {{nowraplinks}}, {{nowrap begin}} and their helper templates. To learn more about those templates click on their names to see their documentation pages. The HTML entity Lots of text 10 kg more text. It may render like this:
But it will not render like this:
{{nowrap}}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 kg (22 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 {{nowrap|10 kg (22 lb)}} more text.
It may render like this:
Or like this:
But it will not render like this:
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. And the MediaWiki template mechanisms interpret characters like equal signs "
{{nowrap begin}}2 + 2 = 4{{nowrap end}} and
{{nowrap begin}}|2| < 3{{nowrap end}}
It may render like this:
But it will not render like this:
Read more about {{nowrap begin}} + {{nowrap end}} in their own section below. {{nowraplinks}} + {{nowraplinks end}}In lists of links such as inside infoboxes and navboxes, using a lot of Most link lists use a dot as a separator. They usually use the template {{·}}, which contains a
[[Salt and Pepper]]{{·}} [[Curry and Saffron]]
We want it to only line wrap after the dot, but unfortunately it might also line wrap at the spaces inside the links. So it might render like this: Therefore we have {{nowraplinks}} + {{nowraplinks end}}. Nowraplinks prevents line wraps inside links (links containing spaces) and only allows line wraps between the links and in normal text. Like this:
{{nowraplinks}}
[[Salt and Pepper]]{{·}} [[Curry and Saffron]]
{{nowraplinks end}}
It may render like this: But it will not render like this: The nowraplinks functionality is also available via the nowraplinks class. The standard navboxes automatically use the nowraplinks class, so there is no need to use {{nowraplinks}} + {{nowraplinks end}} inside them. For most link lists the nowraplinks template or class is easy to use and works well. However, there are some exceptions. The next section explains all about that. Nowraplinks shortcomingsBelow is an example that will cause (differing) problems in all web browsers. The example uses the nowraplinks class, which is equivalent to using {{nowraplinks}} + {{nowraplinks end}} in each table cell. Note that the code in the two table cells differs slightly. Try dragging the width of your web browser window so it becomes smaller and smaller and watch how the line wrapping misbehaves:
{| class="wikitable nowraplinks"
|
[[Apollo 11]] (1969){{·}} [[Apollo 12]] (1969){{·}}
[[Apollo 14]] (1971){{·}} [[Apollo 15]] (1971){{·}}
[[Apollo 16]] (1972){{·}} [[Apollo 17]] (1972)
|
[[Apollo 11]](1969){{·}} [[Apollo 12]](1969){{·}}
[[Apollo 14]](1971){{·}} [[Apollo 15]](1971){{·}}
[[Apollo 16]](1972){{·}} [[Apollo 17]](1972)
|}
It renders this:
The left table cell:
The right table cell:
The best solution is to use {{nowrap begin}} + {{wrap}} + {{nowrap end}} on the lists that would otherwise fail. Fortunately, this solution seems to work very well in all web browsers. You can read more about it in the next section. {{nowrap begin}} + {{·w}} + {{nowrap end}}{{nowrap begin}} + {{nowrap end}} prevents line wraps in text and links containing spaces. To tell exactly where wraps may occur use the helper template {{wrap}}. For convenience there are some additional helper templates like the {{·w}} (a shortcut to {{·wrap}}), which is equivalent to writing Note! The helper templates may only be used in sections surrounded by {{nowrap begin}} and {{nowrap end}} or they may cause weird behaviour on your page. Below is the same example that caused problems with nowraplinks, but now using {{nowrap begin}} + {{·w}} + {{nowrap end}}. Try dragging the width of your web browser window so it becomes smaller and smaller and see how the line wrapping now only occurs right after the dots:
{| class="wikitable"
|
{{nowrap begin}}
[[Apollo 11]] (1969){{·w}} [[Apollo 12]] (1969){{·w}}
[[Apollo 14]] (1971){{·w}} [[Apollo 15]] (1971){{·w}}
[[Apollo 16]] (1972){{·w}} [[Apollo 17]] (1972)
{{nowrap end}}
|
{{nowrap begin}}
[[Apollo 11]](1969){{·w}} [[Apollo 12]](1969){{·w}}
[[Apollo 14]](1971){{·w}} [[Apollo 15]](1971){{·w}}
[[Apollo 16]](1972){{·w}} [[Apollo 17]](1972)
{{nowrap end}}
|}
It renders this:
The left cell shows the style that is usually preferred, with a space between the link and any explanatory text. {{nowrap begin}} and its helper templates work well even if they are surrounded by the nowraplinks template or class. They also avoid Firefox's "expanding outside the cell" bug. Thus {{nowrap begin}} + {{·w}} + {{nowrap end}} can (and should) be used on lines in the standard navboxes that fail due to the nowraplinks problems. What about <nobr> + <wbr> + </nobr> ?{{nowrap begin}} + {{wrap}} + {{nowrap end}} work much like the old, proprietary HTML elements See also |
This article is from Wikipedia. All text is available under the terms of the GNU Free Documentation License.
Mercedes Car
This site monitored by SitePinger.net