# MediaWiki Wikitext Syntax Reference Complete syntax reference for MediaWiki wikitext markup. ## Text Formatting (Inline) | Syntax | Result | Notes | |--------|--------|-------| | `''text''` | *italic* | Two single quotes | | `'''text'''` | **bold** | Three single quotes | | `'''''text'''''` | ***bold italic*** | Five single quotes | | `text` | `monospace` | Inline code | | `x` | Variable style | | | `Ctrl` | Keyboard input | | | `output` | Sample output | | | `2` | Subscript | H₂O | | `2` | Superscript | x² | | `text` | ~~strikethrough~~ | | | `text` | Deleted text | Semantic | | `text` | Inserted text | Often underlined | | `text` | Underline | | | `text` | Small text | | | `text` | Large text | Deprecated | ## Headings ```wikitext = Level 1 = (Don't use - reserved for page title) == Level 2 == === Level 3 === ==== Level 4 ==== ===== Level 5 ===== ====== Level 6 ====== ``` **Rules:** - Must start at line beginning - No text after closing equals on same line - 4+ headings auto-generate TOC (unless `__NOTOC__`) - Spaces around heading text are optional but recommended ## Lists ### Unordered (Bullet) Lists ```wikitext * Item 1 * Item 2 ** Nested item 2.1 ** Nested item 2.2 *** Deeper nesting * Item 3 ``` ### Ordered (Numbered) Lists ```wikitext # First item # Second item ## Sub-item 2.1 ## Sub-item 2.2 ### Sub-sub-item # Third item ``` ### Definition Lists ```wikitext ; Term 1 : Definition 1 ; Term 2 : Definition 2a : Definition 2b ``` ### Mixed Lists ```wikitext # Numbered item #* Bullet under numbered #* Another bullet # Next numbered #: Definition-style continuation ``` ### Indentation ```wikitext : Single indent :: Double indent ::: Triple indent ``` **Note:** List markers must be at line start. Blank lines end the list. ## Links ### Internal Links ```wikitext [[Page Name]] [[Page Name|Display Text]] [[Page Name#Section]] [[Page Name#Section|Display Text]] [[Namespace:Page Name]] [[/Subpage]] [[../Sibling Page]] ``` ### External Links ```wikitext [https://example.com] Numbered link [1] [https://example.com Display Text] Named link https://example.com Auto-linked ``` ### Special Links ```wikitext [[File:Image.jpg]] Embed image [[File:Image.jpg|thumb|Caption]] Thumbnail with caption [[File:Image.jpg|thumb|left|200px|Caption]] [[Media:File.pdf]] Direct file link [[Category:Category Name]] Add to category [[:Category:Category Name]] Link to category (no add) [[Special:RecentChanges]] Special page ``` ### Interwiki Links ```wikitext [[en:English Article]] Language link [[wikt:word]] Wiktionary [[commons:File:Image.jpg]] Wikimedia Commons ``` ## Images ### Basic Syntax ```wikitext [[File:Example.jpg|options|caption]] ``` ### Image Options | Option | Description | |--------|-------------| | `thumb` | Thumbnail (default right-aligned) | | `frame` | Framed, no resize | | `frameless` | Thumbnail without frame | | `border` | Thin border | | `right`, `left`, `center`, `none` | Alignment | | `200px` | Width | | `x100px` | Height | | `200x100px` | Max dimensions | | `upright` | Smart scaling for tall images | | `upright=0.5` | Custom ratio | | `link=Page` | Custom link target | | `link=` | No link | | `alt=Text` | Alt text for accessibility | ### Gallery ```wikitext File:Image1.jpg|Caption 1 File:Image2.jpg|Caption 2 File:Image1.jpg File:Image2.jpg ``` ## Tables ### Basic Structure ```wikitext {| class="wikitable" |+ Caption |- ! Header 1 !! Header 2 !! Header 3 |- | Cell 1 || Cell 2 || Cell 3 |- | Cell 4 || Cell 5 || Cell 6 |} ``` ### Table Elements | Markup | Location | Meaning | |--------|----------|---------| | `{|` | Start | Table start | | `|}` | End | Table end | | `|+` | After `{|` | Caption | | `|-` | Row | Row separator | | `!` | Cell | Header cell | | `!!` | Cell | Header cell separator (same row) | | `|` | Cell | Data cell | | `||` | Cell | Data cell separator (same row) | ### Cell Attributes ```wikitext | style="background:#fcc" | Red background | colspan="2" | Spans 2 columns | rowspan="3" | Spans 3 rows ! scope="col" | Column header ! scope="row" | Row header ``` ### Sortable Table ```wikitext {| class="wikitable sortable" |- ! Name !! Value |- | Alpha || 1 | Beta || 2 |} ``` ## References ### Basic Citation ```wikitext StatementSource information == References == {{Reflist}} ``` ### Named References ```wikitext First useSmith, 2020, p. 42 Second use ``` ### Grouped References ```wikitext NoteExplanatory note SourceRegular citation == Notes == {{Reflist|group="note"}} == References == {{Reflist}} ``` ## Special Tags ### nowiki (Escape Markup) ```wikitext [[Not a link]] <nowiki> Outputs: ``` ### pre (Preformatted) ```wikitext
Preformatted text
  Whitespace preserved
  '''Markup not processed'''
``` ### syntaxhighlight (Code) ```wikitext def hello(): print("Hello") # Line numbers starting at 10 ``` Supported languages: python, javascript, php, java, c, cpp, csharp, ruby, perl, sql, xml, html, css, json, yaml, bash, etc. ### math (LaTeX) ```wikitext Inline: E = mc^2 Block: \sum_{i=1}^n i = \frac{n(n+1)}{2} Chemistry: H2O ``` ### Transclusion Control ```wikitext Only when transcluded Only on template page itself Only this part is transcluded ``` ## HTML Entities | Entity | Character | Description | |--------|-----------|-------------| | `&` | & | Ampersand | | `<` | < | Less than | | `>` | > | Greater than | | ` ` | (space) | Non-breaking space | | `—` | — | Em dash | | `–` | – | En dash | | `→` | → | Right arrow | | `←` | ← | Left arrow | | `©` | © | Copyright | | `€` | € | Euro | | `:` | : | Colon (in definition lists) | ## Miscellaneous ### Horizontal Rule ```wikitext ---- ``` ### Comments ```wikitext ``` ### Line Breaks ```wikitext Line 1
Line 2 ``` ### Redirect ```wikitext #REDIRECT [[Target Page]] #REDIRECT [[Target Page#Section]] ``` Must be first line of page. ### Signatures (Talk pages) ```wikitext ~~~ Username only ~~~~ Username and timestamp ~~~~~ Timestamp only ``` ### Categories ```wikitext [[Category:Category Name]] [[Category:Category Name|Sort Key]] {{DEFAULTSORT:Sort Key}} ``` Place at end of article.