Help:Wikitext examples

From Meta, a Wikimedia project coordination wiki
Jump to: navigation, search
MediaWiki Handbook: Contents, Readers, Editors, Moderators, System admins, Researchers +/-
For basic information see Help:Editing.

Basic text formatting[edit]

You can format the page using Wikitext special characters.

What it looks like What you type

You can italicize text by putting 2 apostrophes on each side.

3 apostrophes will bold the text.

5 apostrophes will bold and italicize the text.

(Using 4 apostrophes doesn't do anything special --
3 of them bold the text as usual; the others are 'just' apostrophes around the text.)

You can ''italicize'' text by putting 2 
apostrophes on ''each'' side. 

3 apostrophes will '''bold''' the text. 

5 apostrophes will '''''bold and italicize''''' 
the text.

(Using 4 apostrophes doesn't do anything
special -- <br /> 3 of them '''bold''' the text as
usual; the others are ''''just'''' apostrophes 
around the text.)

A single newline generally has no effect on the layout. These can be used to separate sentences within a paragraph. Some editors find that this aids editing and improves the diff function (used internally to compare different versions of a page).

But an empty line starts a new paragraph.

When used in a list, a newline does affect the layout (see below).

A single newline
generally has no effect on the layout.
These can be used to separate
sentences within a paragraph.
Some editors find that this aids editing
and improves the ''diff'' function
(used internally to compare
different versions of a page).

But an empty line
starts a new paragraph.

When used in a list, a newline ''does''
affect the layout ([[#lists|see below]]).

You can break lines
without a new paragraph.
Please use this sparingly.

Please do not start a link or italics or bold text on one line and end on the next.

You can break lines<br/>
without a new paragraph.<br/>
Please use this sparingly.

Please do not start a link or
''italics'' or '''bold''' text on one line
and end on the next.
You should "sign" your comments on talk pages:
  • Three tildes gives your signature: Example
  • Four tildes give your signature plus date/time: Example 07:46, 27 November 2005 (UTC)
  • Five tildes gives the date/time alone: 07:46, 27 November 2005 (UTC)
You should "sign" your comments 
on talk pages:
* Three tildes gives your
signature: ~~~
* Four tildes give your 
signature plus date/time: ~~~~
* Five tildes gives the 
date/time alone: ~~~~~

HTML tags[edit]

Main article: Help:HTML in wikitext

You can use some HTML tags, too. However, you should avoid HTML in favor of Wiki markup whenever possible.


What it looks like What you type

Put text in a typewriter font. The same font is generally used for computer code.

Put text in a <tt>typewriter
font</tt>. The same font is 
generally used for <code>
computer code</code>.

Strike out or underline text, or write it in small caps.

<strike>Strike out</strike>
or <u>underline</u> text,
or write it <span style=
"font-variant:small-caps">
in small caps</span>.

Superscripts and subscripts: X2, H2O

Superscripts and subscripts:
X<sup>2</sup>, H<sub>2</sub>O
Centered text
  • Please note the American spelling of "center".
<center>Centered text</center>
* Please note the American spelling of "center".

The blockquote command formats block quotations, typically by surrounding them with whitespace and a slightly different font.

<blockquote>
The '''blockquote''' command ''formats'' block 
quotations, typically by surrounding them 
with whitespace and a slightly different font.
</blockquote>

Invisible comments to editors (<!-- -->) appear only while editing the page.

  • If you wish to make comments to the public, you should usually use the talk page.
Invisible comments to editors (<!-- -->)
appear only while editing the page.
<!-- Note to editors: blah blah blah. -->

Organizing your writing[edit]

See also: w:Picture tutorial
What it looks like What you type

Headings organize your writing into sections. The Wiki software can automatically generate a table of contents from them.


Subsection

Using more "equals" (=) signs creates a subsection.

A smaller subsection

Don't skip levels, like from two to four equals signs.

Start with 2 equals signs not 1 because 1 creates H1 tags which should be reserved for page title.

== Section headings ==

''Headings'' organize your writing into 
sections. The ''Wiki'' software can automatically 
generate a [[help:Section|table of contents]] from them.

=== Subsection ===
Using more "equals" (=) signs creates a subsection.

==== A smaller subsection ====

Don't skip levels, like from two to four equals signs.

Start with 2 equals signs not 1 because 1 creates H1 
tags which should be reserved for page title.
  • Unordered lists are easy to do:
    • Start every line with a star.
      • More stars indicate a deeper level.
    Previous item continues.
    • A newline
  • in a list

marks the end of the list.

  • Of course you can start again.
* ''Unordered lists'' are easy to do:
** Start every line with a star.
*** More stars indicate a deeper level.
*: Previous item continues.
** A newline
* in a list  
marks the end of the list.
*Of course you can start again.
  1. Numbered lists are:
    1. Very organized
    2. Easy to follow

A newline marks the end of the list.

  1. New numbering starts with 1.
# ''Numbered lists'' are:
## Very organized
## Easy to follow
A newline marks the end of the list.
# New numbering starts with 1.

Here's a definition list:

Word 
Definition of the word
A longer phrase needing definition
Phrase defined
A word 
Which has a definition
Also a second definition
And even a third

Begin with a semicolon. One item per line; a newline can appear before the colon, but using a space before the colon improves parsing.

Here's a ''definition list'':
; Word : Definition of the word
; A longer phrase needing definition
: Phrase defined
; A word : Which has a definition
: Also a second definition
: And even a third

Begin with a semicolon. One item per line; 
a newline can appear before the colon, but 
using a space before the colon improves 
parsing.
  • You can even do mixed lists
    1. and nest them
    2. inside each other
      • or break lines
        in lists.
      definition lists
      can be
      nested 
      too
* You can even do mixed lists
*# and nest them
*# inside each other
*#* or break lines<br>in lists.
*#; definition lists
*#: can be 
*#:; nested : too
A colon (:) indents a line or paragraph.

A newline starts a new paragraph.
Should only be used on talk pages.
For articles, you probably want the blockquote tag.

We use 1 colon to indent once.
We use 2 colons to indent twice.
3 colons to indent 3 times, and so on.
: A colon (:) indents a line or paragraph.
A newline starts a new paragraph.
Should only be used on talk pages.
For articles, you probably want the blockquote tag.
: We use 1 colon to indent once.
:: We use 2 colons to indent twice.
::: 3 colons to indent 3 times, and so on.

You can make horizontal dividing lines (----) to separate text.


But you should usually use sections instead, so that they go in the table of contents.

You can make ''horizontal dividing lines'' 
(----) to separate text.
----
But you should usually use sections instead,
so that they go in the table of contents.

You can add footnotes to sentences using the ref tag -- this is especially good for citing a source.

There are over six billion people in the world.[1]
References:
  1. CIA World Factbook, 2006.

For details, see Wikipedia:Footnotes and Help:Footnotes.

You can add footnotes to sentences using
the ''ref'' tag -- this is especially good
for citing a source.

:There are over six billion people in the
world.<ref>CIA World Factbook, 2006.</ref>

References: <references/>

For details, see [[Wikipedia:Footnotes]] 
and [[Help:Footnotes]].

Links[edit]

Main article: Help:Link

You will often want to make clickable links to other pages.

What it looks like What you type

Here's a link to a page named Official position. You can even say official positions and the link will show up correctly.

Here's a link to a page named [[Official positions|Official position]].
You can even say [[official positions]]
and the link will show up correctly.

You can put formatting around a link. Example: Wikipedia.

You can put formatting around a link.
Example: ''[[Wikipedia]]''.

The first letter of articles is automatically capitalized, so wikipedia goes to the same place as Wikipedia. Capitalization matters after the first letter.

The ''first letter'' of articles is automatically
capitalized, so [[wikipedia]] goes to the same place
as [[Wikipedia]]. Capitalization matters after the
first letter.

Intentionally permanent red link is a page that doesn't exist yet. You could create it by clicking on the link.

[[Intentionally permanent red link]] is a page that doesn't exist
yet. You could create it by clicking on the link.

You can link to a page section by its title:

If multiple sections have the same title, add a number. #Example section 3 goes to the third section named "Example section".

You can link to a page section by its title:

* [[Doxygen#Doxygen Examples]].

If multiple sections have the same title, add
a number. [[#Example section 3]] goes to the
third section named "Example section".

You can make a link point to a different place with a piped link. Put the link target first, then the pipe character "|", then the link text.

Or you can use the "pipe trick" so that a title that contains disambiguation text will appear with more concise link text.

You can make a link point to a different place
with a [[Help:Piped link|piped link]]. Put the link
target first, then the pipe character "|", then
the link text.

* [[Help:Link|About Links]]
* [[List of cities by country#Morocco|Cities in Morocco]]

Or you can use the "pipe trick" so that a title that
contains disambiguation text will appear with more concise
link text.

* [[Spinning (textiles)|]]
* [[Boston, Massachusetts|]]

You can make an external link just by typing a URL: http://www.nupedia.com

You can give it a title: Nupedia

Or leave the title blank: [1]

External link can be used to link to a wiki page that cannot be linked to with [[page]]: http://meta.wikimedia.org/w/index.php?title=Fotonotes&oldid=482030#Installation

You can make an external link just by typing a URL:
http://www.nupedia.com

You can give it a title:
[http://www.nupedia.com Nupedia]

Or leave the title blank:
[http://www.nupedia.com]

External link can be used to link to a wiki page that
cannot be linked to with <nowiki>[[page]]</nowiki>:
http://meta.wikimedia.org/w/index.php?title=Fotonotes
&oldid=482030#Installation

Linking to an e-mail address works the same way: mailto:someone@example.com or someone

Linking to an e-mail address works the same way:
mailto:someone@example.com or [mailto:someone@example.com someone]

You can redirect the user to another page.

#REDIRECT [[Official positions|Official position]]

Category links do not show up in line but instead at page bottom and cause the page to be listed in the category.

Add an extra colon to link to a category in line without causing the page to be listed in the category: Category:English documentation

[[Help:Category|Category links]] do not show up in line
but instead at page bottom
''and cause the page to be listed in the category.''
[[Category:English documentation]]

Add an extra colon to ''link'' to a category in line
without causing the page to be listed in the category:
[[:Category:English documentation]]

The Wiki reformats linked dates to match the reader's date preferences. These three dates will show up the same if you choose a format in your Preferences:

The Wiki reformats linked dates to match the reader's
date preferences. These three dates will show up the
same if you choose a format in your
[[Special:Preferences|]]:
* [[1969-07-20]]
* [[July 20]], [[1969]]
* [[20 July]] [[1969]]

Just show what I typed[edit]

A few different kinds of formatting will tell the Wiki to display things as you typed them.

What it looks like What you type
The pre tag ignores [[Wiki]]
 ''markup''.
It also doesn't     reformat
 text.
It still interprets special
characters: →
<pre>
The pre tag ignores [[Wiki]]
 ''markup''.
It also doesn't     reformat
 text.
It still interprets special
characters: &rarr;
</pre>

The nowiki tag ignores [[Wiki]] ''markup''. It reformats text by removing newlines and multiple spaces. It still interprets special characters: →

<nowiki>
The nowiki tag ignores 
[[Wiki]] ''markup''.
It reformats text by 
removing
newlines    and multiple
 spaces.
It still interprets special
characters: &rarr;
</nowiki>

Leading spaces are another way to preserve formatting.

Putting a space at the
beginning of each
line stops the text   
from being
reformatted.  It still 
interprets Wiki
markup and special
characters: →
 Putting a space at the
 beginning of each
 line stops the text
 from being
 reformatted.  It still 
 interprets [[Wiki]]
 ''markup'' and special
 characters: &rarr;

As you can see in the examples above, all three formatting options still interpret special characters (E.g. &rarr; as →). If you want the displayed text to to appear as if this intrepretation was not happening, replace the ampersand in each of the special characters with &amp;. (E.g. &amp;rarr; will display as &rarr;)

It's not necessary to replace the ampersand when it's not part of a special character (E.g. Search & Replace will appear as "Search & Replace"). But it's fine to do so. (Search &amp; Replace will appear as "Search & Replace".) If you're creating a tool that generates mediawiki text, where special characters should appear as if they're not interpretted, it may be simplest to replace all ampersands with &amp;.

<pre> and <nowiki> are both terminated by the first matching end tag found (</pre> or </nowiki>). They don't nest; embedding another <pre> and <nowiki> start tag doesn't mean that next end tag will be ignored. If you want to include an end tag in the formatted text, one way to create that appearance is to replace the less than character with &lt;. (I.e. &lt;/pre> or &lt;/nowiki> will be displayed as </pre> or </nowiki>). If you're creating a tool that generates mediawiki text, where an end tag might appear in the formatted text, it may be simplest to replace all less than characters with &lt;.

Source code[edit]

If the syntax highlighting extension is installed, you can display programming language source code in a manner very similar to the HTML <pre> tag, except with the type of syntax highlighting commonly found in advanced text editing software.

Here's an example of how to display some C# source code:

<source lang="csharp">
// Hello World in Microsoft C# ("C-Sharp").

using System;

class HelloWorld
{
    public static int Main(String[] args)
    {
        Console.WriteLine("Hello, World!");
        return 0;
    }
}
</source>

Results in:

// Hello World in Microsoft C# ("C-Sharp").
 
using System;
 
class HelloWorld
{
    public static int Main(String[] args)
    {
        Console.WriteLine("Hello, World!");
        return 0;
    }
}

Images, tables, video, and sounds[edit]

This is a very quick introduction. For more information, see:

After uploading, just enter the filename, highlight it and press the "embedded image"-button of the edit_toolbar.

This will produce the syntax for uploading a file [[Image:filename.png]]

What it looks like What you type

A picture, including alternate text:

This is Wiki's logo

You can put the image in a frame with a caption:

This is Wiki's logo
A picture, including alternate text:

[[Image:Wiki.png|This is Wiki's logo]]

You can put the image in a frame with a caption:
[[Image:Wiki.png|frame|This is Wiki's logo]]

A link to Wikipedia's page for the image: Image:Wiki.png

Or a link directly to the image itself: Media:Wiki.png

A link to Wikipedia's page for the image:
[[:Image:Wiki.png]]

Or a link directly to the image itself:
[[Media:Wiki.png]]
Use media: links to link

directly to sounds or videos: A sound file

Use '''media:''' links to link
directly to sounds or videos:
[[media:Classical guitar scale.ogg|A sound file]]
Provide a spoken rendition of some text in a template:
Audio
Flow my tears 250px(583KB, help | download | file info)
Provide a spoken rendition of some text in a template:
{{listen
 |title    = Flow my tears
 |filename = Flow my tears.ogg
 |filesize = 583KB
}}
This is
a table
{| border="1" cellspacing="0" cellpadding="5" align="center"
|-
! This
! is
|- 
| a
| table
|}

Galleries[edit]

Main article: w:Gallery tag

Images can also be grouped into galleries using the <gallery> tag, such as the following:

Mathematical formulae[edit]

You can format mathematical formulae with TeX markup.

What it looks like What you type
\sum_{n=0}^\infty \frac{x^n}{n!}
<math>\sum_{n=0}^\infty \frac{x^n}{n!}</math>

Templates[edit]

Main article: Help:Template

Templates are segments of Wiki markup that are meant to be copied automatically ("transcluded") into a page. You add them by putting the template's name in {{double braces}}. It is also possible to transclude other pages by using {{:colon and double braces}}.

Some templates take parameters, as well, which you separate with the pipe character.

What it looks like What you type

This text comes from the page named Template:Transclusion demo. It has been transcluded into this page.

{{Transclusion demo}}

This transclusion demo is a little bit of text from the page Help:Transclusion Demo to be included into any file.

{{Help:Transclusion Demo}}

This template takes two parameters, and creates underlined text with a hover box for many modern browsers supporting CSS:

Hover your mouse over this text

Go to this page to see the H:title template itself: {{H:title}}

This template takes two parameters, and
creates underlined text with a hover box
for many modern browsers supporting CSS:

{{H:title|This is the hover text|
Hover your mouse over this text}}

Go to this page to see the H:title template
itself: {{tl|H:title}}

Links to other help pages[edit]

Help contents
Meta · Wikinews · Wikipedia · Wikiquote · Wiktionary · Commons: · Wikidata · MediaWiki · Wikibooks · Wikisource · MediaWiki: Manual · Google
Versions of this help page (for other languages see further)
What links here on Meta or from Meta · Wikipedia · MediaWiki
Reading
Go · Search · Stop words · Namespace · Page name · Section · Backlinks · Redirect · Category · Image page · Special pages · Printable version
Tracking changes
Recent changes (enhanced) | Related changes · Watching pages · Diff · Page history · Edit summary · User contributions · Minor edit · Patrolled edit
Logging in and preferences
Logging in · Preferences · User style
Editing
Starting a new page · Advanced editing · Editing FAQ · Edit toolbar · Export · Import · Shortcuts · Edit conflict · Page size
Referencing
Links · URL · Piped links · Interwiki linking · Footnotes
Style and formatting
Wikitext examples · CSS · Reference card · HTML in wikitext · Formula · List · Table · Sorting · Colors · Images and file uploads
Fixing mistakes
Show preview · Testing · Reverting edits
Advanced functioning
Expansion · Template · Advanced templates · Parser function · Parameter default · Variable · System message · Substitution · Array · Calculation · Embed page
Others
Special characters · Renaming (moving) a page · Preparing a page for translation · Talk page · Signatures · Sandbox · Legal issues for editors
Languages: English  · Deutsch · français · português · português do Brasil · shqip