MediaWiki Markup: The Complete Table Format Guide
MediaWiki powers some of the world's most visited websites, including Wikipedia, Wiktionary, and countless corporate wikis. If you've ever edited a wiki page and struggled with table formatting, you're not alone. MediaWiki's table syntax — often called "pipe syntax" — has a learning curve, but once mastered, it lets you create rich, sortable, well-formatted tables directly in wiki markup.
This guide covers everything from basic table creation to advanced features like row spanning, sortable columns, and nested tables.
MediaWiki Table Syntax Basics
MediaWiki tables use a pipe-based syntax that maps to HTML table elements. Every table starts with {| and ends with |}. Here's the minimal structure:
{| class="wikitable"
|-
! Header 1 !! Header 2 !! Header 3
|-
| Row 1, Col 1 || Row 1, Col 2 || Row 1, Col 3
|-
| Row 2, Col 1 || Row 2, Col 2 || Row 2, Col 3
|}
Let's break down the key symbols:
| Symbol | Meaning | HTML Equivalent |
|---|---|---|
{| |
Table start | <table> |
|} |
Table end | </table> |
|- |
New row | <tr> |
! |
Header cell | <th> |
| |
Data cell | <td> |
!! |
Header cells on same line | Multiple <th> |
|| |
Data cells on same line | Multiple <td> |
|+ |
Table caption | <caption> |
Table Classes: Styling Your Tables
MediaWiki provides built-in CSS classes that transform plain tables into professionally styled ones. These classes are added to the opening {| tag.
The wikitable Class
The most common class, wikitable, adds borders, padding, and alternating header styling:
{| class="wikitable"
|+ Population Data
|-
! City !! Population !! Country
|-
| Tokyo || 13,960,000 || Japan
|-
| Delhi || 11,030,000 || India
|-
| Shanghai || 24,870,000 || China
|}
The sortable Class
Adding sortable enables JavaScript-powered column sorting, allowing users to click headers to sort data ascending or descending:
{| class="wikitable sortable"
|-
! Name !! Age !! Score
|-
| Alice || 28 || 95
|-
| Bob || 34 || 87
|-
| Charlie || 22 || 91
|}
Combining Classes
You can combine multiple classes for enhanced functionality:
{| class="wikitable sortable mw-collapsible"
|-
! Feature !! Status
|-
| Sorting || ✓ Enabled
|-
| Collapsible || ✓ Enabled
|}
The mw-collapsible class adds a show/hide toggle, perfect for large tables that might clutter a page.
Cell Formatting and Attributes
Individual cells can receive HTML attributes by placing them before the content, separated by a single pipe:
{| class="wikitable"
|-
! style="background: #4CAF50; color: white;" | Status
! style="width: 200px;" | Description
|-
| style="text-align: center;" | Active || Currently running
|-
| style="text-align: center; color: red;" | Inactive || Service suspended
|}
Common cell attributes include:
style="background: #hex;"— Background colorstyle="text-align: center;"— Text alignmentstyle="width: 150px;"— Column widthstyle="font-weight: bold;"— Bold text
Spanning Rows and Columns
Like HTML tables, MediaWiki supports colspan and rowspan for merging cells:
Column Spanning
{| class="wikitable"
|-
! colspan="3" | Q1 2025 Report
|-
! Month !! Revenue !! Growth
|-
| January || $45,000 || 12%
|-
| February || $52,000 || 15%
|-
| March || $48,000 || 7%
|}
Row Spanning
{| class="wikitable"
|-
! rowspan="2" | Product
! colspan="2" | Sales
|-
! Q1 !! Q2
|-
| Widget A || 150 || 200
|-
| Widget B || 300 || 250
|}
Nested Tables
MediaWiki allows tables within tables, though this should be used sparingly to maintain readability:
{| class="wikitable"
|-
! Category !! Details
|-
| Fruits ||
{| class="wikitable"
|-
| Apple || Red
|-
| Banana || Yellow
|}
|-
| Vegetables ||
{| class="wikitable"
|-
| Carrot || Orange
|-
| Broccoli || Green
|}
|}
Tip: Nested tables increase source complexity significantly. Consider whether a flat table with additional columns would serve the same purpose more cleanly.
Row and Table Attributes
You can apply attributes to entire rows using the |- row separator:
{| class="wikitable"
|- style="background: #f0f0f0;"
| Row with gray background || Second cell
|- style="background: #e8f5e9;"
| Row with green tint || Second cell
|}
Table-level attributes go directly after the opening {|:
{| class="wikitable" style="width: 80%; margin: auto; border: 2px solid #333;"
|-
! Centered table with custom border
|}
Converting HTML and CSV to MediaWiki
Manually writing MediaWiki table markup for large datasets is tedious and error-prone. If you already have data in HTML tables, CSV spreadsheets, or Excel files, converting them programmatically saves enormous time.
From HTML
HTML tables map directly to MediaWiki syntax — every <tr> becomes |-, every <td> becomes |, and every <th> becomes !. But handling attributes, nested elements, and edge cases makes manual conversion impractical for complex tables.
Use ConvertMatrix's HTML to MediaWiki converter to transform any HTML table into clean wiki markup instantly.
From CSV or Excel
For spreadsheet data, the CSV to MediaWiki converter and Excel to MediaWiki converter handle the translation, including proper header detection and class assignment.
Best Practices for MediaWiki Tables
- Always use the
wikitableclass for consistent, readable styling - Add
sortablefor tables with more than 5 rows of comparable data - Use captions (
|+) to describe what the table contains - Keep tables simple — avoid deeply nested structures
- Test rendering using the preview function before saving
- Use templates for repeated table patterns across multiple pages
- Consider accessibility — use proper header cells (
!) so screen readers can parse the table correctly
Common Mistakes to Avoid
- Forgetting
|-between rows — cells will merge unexpectedly - Missing space after
|— can cause parsing issues with certain cell content - Using HTML instead of wiki syntax — while HTML works, it's harder to maintain and less wiki-friendly
- Overusing colspan/rowspan — makes the source nearly unreadable
Conclusion
MediaWiki's table markup is powerful once you understand its pipe-based syntax. From basic data tables to sortable, collapsible, and styled layouts, you can present complex information effectively on any wiki platform. For quick conversions from existing data, try ConvertMatrix's CSV to MediaWiki, HTML to MediaWiki, or Excel to MediaWiki converters — paste your data, get clean wiki markup, and paste it directly into your wiki page.
Try Our Free Conversion Tools
Put what you've learned into practice with our browser-based converters: