Community Central
Community Central
(Add further help and feedback section)
Tags: Help rte-source
mNo edit summary
(22 intermediate revisions by 15 users not shown)
Line 1: Line 1:
  +
__NOWYSIWYG__
Whitespace, which is any part of text which doesn't contain a visible character such as a space or a line break, generally acts normally as you would expect on Wikia, but there are some situations where whitespace acts counter-intuitively, especially if entered using the classic editor or source mode. Here are just some of those situations, and how to avoid them.
+
'''Whitespace''' is any part of text which doesn't contain a visible character. It generally acts normally, but there are some situations where whitespace acts counter-intuitively, especially if entered using [[Help:Source edit mode|source mode]] (in either [[Help:VisualEditor|VisualEditor]] or the [[Help:Classic editor|classic editor]]). This page lists some of those situations, and how to avoid them.
   
==Line Breaks==
+
== Line breaks ==
To get a line break to display on the page, two line breaks (or two presses of the enter/return key on your keyboard) are needed. If you only use one line break, the text after the line break will just continue on next to the text above it as if separated by a normal space character. For example:
+
To get a line break to display on the page, two line breaks (or two presses of the enter/return key on your keyboard) are needed. If you only use one line break, the text after the line break will just continue on next to the text above it as if separated by a normal space character. For example:
  +
<pre>
 
  +
{| cellpadding="0" style="border: 1px solid #ccc; margin: 1em auto; width: 85%;"
Hello
 
  +
|-
  +
|style="background: #FAFAFA; color: #111; padding: 0.5em; font-family: monospace;"|
 
Hello<br/>
 
World
 
World
  +
|-
</pre>
 
  +
|style="text-align: center; font-size: 90%; font-weight: bold;"|Displays as:
turns into:
 
  +
|-
 
  +
|style="padding: 0.5em;"|
 
Hello
 
Hello
 
World
 
World
  +
|}
   
  +
By comparison:
<pre>
 
  +
  +
{| cellpadding="0" style="border: 1px solid #ccc; margin: 1em auto; width: 85%;"
  +
|-
  +
|style="background: #FAFAFA; color: #111; padding: 0.5em; font-family: monospace;"|
 
Hello
 
Hello
   
 
World
 
World
  +
|-
</pre>
 
  +
|style="text-align: center; font-size: 90%; font-weight: bold;"|Displays as:
turns into:
 
  +
|-
 
  +
|style="padding: 0.5em;"|
 
Hello
 
Hello
   
World.
+
World
  +
|}
   
 
However, single line breaks don't follow this pattern when part of a list of either ordered or unordered type. For example, using an unordered list:
 
However, single line breaks don't follow this pattern when part of a list of either ordered or unordered type. For example, using an unordered list:
<pre>
 
*Item 1
 
*Item 2
 
List ended.
 
</pre>
 
Will display as:
 
   
  +
{| cellpadding="0" style="border: 1px solid #ccc; margin: 1em auto; width: 85%;"
*Item 1
 
  +
|-
*Item 2
 
  +
|style="background: #FAFAFA; color: #111; padding: 0.5em; font-family: monospace;"|
  +
<nowiki>*</nowiki> Item 1<br/>
  +
<nowiki>*</nowiki> Item 2<br/>
 
List ended.
 
List ended.
  +
|-
  +
|style="text-align: center; font-size: 90%; font-weight: bold;"|Displays as:
  +
|-
  +
|style="padding: 0.5em;"|
 
* Item 1
 
* Item 2
 
List ended.
  +
|}
   
This specific problem is often encountered when a single line space is used inside a template for information layout in the source code, causing some templates to force a line break when used inside a list.
+
When a line space is used inside a template it may end up being passed through to the article page, which can cause an unexpected line break when used inside a list. To prevent this, avoid unwarranted line breaks in templates.
   
 
== Multiple spaces in a row ==
==Whitespace at the beginning of lines==
 
If a space is added at the beginning of a line or paragraph, all the following text will be placed inside a one line high box. For example:
 
<pre>
 
Hello world! Did you know that you can learn more about links at [[Help:Link]]?
 
</pre>
 
Turns into:
 
 
Hello world! Did you know that you can learn more about links at [[Help:Link]]?
 
As you can see, this box is similar to the box formed by pre tags, however it does parse wikitext (ie changes things written in MediaWiki code into the thing they're meant to display, instead of leaving it as the code for others to see), unlike the pre tags.
 
 
==Multiple spaces in a row==
 
 
If you intend to separate text with multiple spaces, all those spaces will be condensed down to one single space instead of giving the desired spacing. For example:
 
If you intend to separate text with multiple spaces, all those spaces will be condensed down to one single space instead of giving the desired spacing. For example:
<pre>
 
White Space
 
</pre>
 
Turns into:
 
   
  +
{| cellpadding="0" style="border: 1px solid #ccc; margin: 1em auto; width: 85%;"
White Space
 
  +
|-
  +
|style="background: #FAFAFA; color: #111; padding: 0.5em; font-family: monospace;"|
 
White&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Space
  +
|-
  +
|style="text-align: center; font-size: 90%; font-weight: bold;"|Displays as:
  +
|-
  +
|style="padding: 0.5em;"|
  +
White Space<!-- Please do not remove the spaces or add non-breaking spaces here -->
  +
|}
   
This can be avoided by using what is known as a [[wikipedia:non-breaking space|non-breaking space]] which doesn't collapse when a page is displayed to the reader. This is produced by typing &amp;nbsp;. For example:
+
This can be avoided by using what is known as a [[wikipedia:non-breaking space|non-breaking space]] which doesn't collapse when a page is displayed to the reader. This is produced by typing <code>&amp;nbsp;</code>. For example:
<pre>
 
White&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Space
 
</pre>
 
Displays as:
 
   
  +
{| cellpadding="0" style="border: 1px solid #ccc; margin: 1em auto; width: 85%;"
  +
|-
  +
|style="background: #FAFAFA; color: #111; padding: 0.5em; font-family: monospace;"|
  +
White&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Space
  +
|-
  +
|style="text-align: center; font-size: 90%; font-weight: bold;"|Displays as:
  +
|-
  +
|style="padding: 0.5em;"|
 
White&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Space
 
White&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Space
  +
|}
   
Note that this is only the case for normal space characters. Line breaks won't collapse on themselves with the exception of when a single line break is used, as documented above.
+
Note that this is only the case for normal space characters. Line breaks won't collapse on themselves with the exception of when a single line break is used, as mentioned above.
   
 
== Whitespace at the beginning of lines ==
==Indentation==
 
 
If a space is added at the beginning of a line or paragraph, all the following text will be placed inside a one line high box. For example:
So what do you do if you want to indent your text, since you can't use spaces? Well, use colons! The more colons you put at the beginning of your line of text, the more indented it will be. For example:
 
  +
<pre>
 
  +
{| cellpadding="0" style="border: 1px solid #ccc; margin: 1em auto; width: 85%;"
This is a line of text.
 
  +
|-
:This is an indented line of text.
 
  +
|style="background: #FAFAFA; color: #111; padding: 0.5em; font-family: monospace;"|
::This line of text is more indented.
 
 
&nbsp;Hello world! Did you know that you can learn more about links at <nowiki>[[Help:Links]]</nowiki>?
</pre>
 
  +
|-
Displays as:
 
  +
|style="text-align: center; font-size: 90%; font-weight: bold;"|Displays as:
  +
|-
  +
|style="padding: 0.5em;"|
 
Hello world! Did you know that you can learn more about links at [[Help:Links]]?
  +
|}
  +
  +
This box is similar to the preformatted text box formed by using <code><nowiki><pre></nowiki></code> [[Help:HTML|HTML tags]]. The difference is that the box formed by whitespace at the beginning of lines ''does'' parse [[Help:Wikitext|wikitext]] (see the example above, where <code><nowiki>[[Help:Links]]</nowiki></code> appears as a link).
  +
 
== Indentation ==
  +
Whitespace and non-breaking space characters should be avoided for adding indention to a block of text. The wikitext equivalent, a colon at the beginning of a newline, should be used instead. The level of indentation can be changed using the number of colons placed:
   
  +
{| cellpadding="0" style="border: 1px solid #ccc; margin: 1em auto; width: 85%;"
  +
|-
  +
|style="background: #FAFAFA; color: #111; padding: 0.5em; font-family: monospace;"|
 
This is a line of text.<br/>
 
<nowiki>:</nowiki> This is an indented line of text.<br/>
 
<nowiki>::</nowiki> This line of text is more indented.
  +
|-
  +
|style="text-align: center; font-size: 90%; font-weight: bold;"|Displays as:
  +
|-
  +
|style="padding: 0.5em;"|
 
This is a line of text.
 
This is a line of text.
:This is an indented line of text.
+
: This is an indented line of text.
::This line of text is more indented.
+
:: This line of text is more indented.
  +
|}
   
 
Note that if you're indenting the text, the normal line-break collapsing rules don't apply and you can put a line of different indentation directly under another line.
 
Note that if you're indenting the text, the normal line-break collapsing rules don't apply and you can put a line of different indentation directly under another line.
   
  +
== See also ==
  +
* [[Help:Wikitext|Wikitext help]] and [[Help:Wikitext best practices|best practices]] for it
  +
* [[wikipedia:Whitespace character|Whitespace]] on Wikipedia
   
==Further help and feedback==
+
== Further help and feedback ==
 
{{Help and feedback section}}
 
{{Help and feedback section}}
  +
  +
[[es:Ayuda:Espacio en blanco]]
  +
[[ja:ヘルプ:空白と改行]]
  +
[[vi:Trợ giúp:Khoảng trắng]]
  +
[[zh:Help:空白区域]]
  +
[[Category:Help]]

Revision as of 14:48, 20 June 2019

Whitespace is any part of text which doesn't contain a visible character. It generally acts normally, but there are some situations where whitespace acts counter-intuitively, especially if entered using source mode (in either VisualEditor or the classic editor). This page lists some of those situations, and how to avoid them.

Line breaks

To get a line break to display on the page, two line breaks (or two presses of the enter/return key on your keyboard) are needed. If you only use one line break, the text after the line break will just continue on next to the text above it as if separated by a normal space character. For example:

Hello
World

Displays as:

Hello World

By comparison:

Hello

World

Displays as:

Hello

World

However, single line breaks don't follow this pattern when part of a list of either ordered or unordered type. For example, using an unordered list:

* Item 1
* Item 2
List ended.

Displays as:
  • Item 1
  • Item 2

List ended.

When a line space is used inside a template it may end up being passed through to the article page, which can cause an unexpected line break when used inside a list. To prevent this, avoid unwarranted line breaks in templates.

Multiple spaces in a row

If you intend to separate text with multiple spaces, all those spaces will be condensed down to one single space instead of giving the desired spacing. For example:

White           Space

Displays as:

White Space

This can be avoided by using what is known as a non-breaking space which doesn't collapse when a page is displayed to the reader. This is produced by typing &nbsp;. For example:

White&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Space

Displays as:

White         Space

Note that this is only the case for normal space characters. Line breaks won't collapse on themselves with the exception of when a single line break is used, as mentioned above.

Whitespace at the beginning of lines

If a space is added at the beginning of a line or paragraph, all the following text will be placed inside a one line high box. For example:

 Hello world! Did you know that you can learn more about links at [[Help:Links]]?

Displays as:
Hello world!  Did you know that you can learn more about links at Help:Links?

This box is similar to the preformatted text box formed by using <pre> HTML tags. The difference is that the box formed by whitespace at the beginning of lines does parse wikitext (see the example above, where [[Help:Links]] appears as a link).

Indentation

Whitespace and non-breaking space characters should be avoided for adding indention to a block of text. The wikitext equivalent, a colon at the beginning of a newline, should be used instead. The level of indentation can be changed using the number of colons placed:

This is a line of text.
: This is an indented line of text.
:: This line of text is more indented.

Displays as:

This is a line of text.

This is an indented line of text.
This line of text is more indented.

Note that if you're indenting the text, the normal line-break collapsing rules don't apply and you can put a line of different indentation directly under another line.

See also

Further help and feedback