User:Robchurch/Editing Crash Course/Basic Editing/Whitespace
You may have begun editing a page in MediaWiki only to discover that it displays incorrectly. This is because the software ignores a lot of whitespace, similar to HTML. This lesson details what happens, and explains how to take control of your text.
New lines
[edit]The text below
This is one line This is another line
renders as
This is one line This is another line
Obviously, not what is intended; the sentences ought to be on separate lines. As with HTML, MediaWiki ignores the newline character. Fortunately, we can force MediaWiki to insert a new line using the <br /> tag. For instance:
This is one line
This is another line
now renders as
This is one line
This is another line
New paragraphs
[edit]MediaWiki interprets blank lines between text as an indicator that it should render a new paragraph. Thus:
This is some text in one paragraph. This is some text in another paragraph.
is rendered as
This is some text in one paragraph.
This is some text in another paragraph.
Indenting text
[edit]At times, it is useful to intent paragraphs of text, particularly when responding to comments during a discussion. For this, you need to prefix the line with a colon (:) or more than one colon, depending upon the levels of indentation required. For example:
This is some text :This is some text ::This is some text :::This is some text ::::This is some text
is rendered as
This is some text
- This is some text
- This is some text
- This is some text
- This is some text
- This is some text
- This is some text
Plain text
[edit]If a line is prefixed with a space ( ), MediaWiki renders it as plain text in a new boxout. For example:
This is some text
is rendered as
This is some text
This is useful when giving examples or code; for instance, in this crash course, it is used to give wikimarkup code.
Free form spacing
[edit]Finally, MediaWiki can be instructed to space text exactly as it is spaced in the wikimarkup. This is done using the <pre> and </pre> tags. For example:
<pre>This is some freeform text This is some more freeform text This is yet more freeform text</pre>
is rendered as
This is some freeform text This is some more freeform text This is yet more freeform text