WikiQueer:Line break handling

This page explains different methods for creating, controlling and preventing line breaks and word wraps in WikiQueer 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

 * See also: WikiQueer:Don't use 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. The paragraph is word wrapped where necessary. 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 will break in the middle.

It renders like this:

"A single newline in the code does not cause a visible line break. The paragraph is word wrapped where necessary. 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 will break in the middle."

The  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. The  tag used here is not really HTML markup but "HTML wikimarkup" that gets interpreted by MediaWiki.

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:

In Xanadu did Kubla Khan A stately pleasure-dome decree: Where Alph, the sacred river, ran Through caverns measureless to man Down to a sunless sea.

So twice five miles of fertile ground With walls and towers were girdled round: And there were gardens bright with sinuous rills, Where blossomed many an incense-bearing tree; And here were forests ancient as the hills, Enfolding sunny spots of greenery.

Will render as:

In Xanadu did Kubla Khan A stately pleasure-dome decree: Where Alph, the sacred river, ran Through caverns measureless to man Down to a sunless sea.

So twice five miles of fertile ground With walls and towers were girdled round: And there were gardens bright with sinuous rills, Where blossomed many an incense-bearing tree; And here were forests ancient as the hills, Enfolding sunny spots of greenery.

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:

Lots of text 10&amp;nbsp;kg more text.

It may render like this:
 * Lots of text
 * 10 kg more text.

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

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 occuring, as in:

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

Thus, line wrapping that breaks the section identifier 1&#8209;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.

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

Wrap between (linked) list items
In lists of links such as inside infoboxes and navboxes, use the CSS class hlist 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.

What about &lt;nobr> + &lt;wbr> + &lt;/nobr> ?
Don't use the old, proprietary HTML elements. These elements haven't been made part of XHTML 1.0 by the World Wide Web Consortium, nor does MediaWiki allow them as an extension.

Break tags
WikiQueer currently renders XHTML 1.0 where is valid XHTML and  is invalid. Normally HTML Tidy will convert a variety of malformed versions of the break tag to including, ,  and.

This conversion does not work in a number of MediaWiki interface pages and can cause invalid HTML and problems rendering the page. Other wikis may not have HTML Tidy enabled, thus exported pages using an incorrect break tags will result in invalid HTML.

Eventually, WikiQueer will migrate to HTML5, where both and  are valid.