Shortcut:
P:TABLE

This page explains how to create a table in an article. Tables use fairly complicated syntax in MediaWiki, but there are simple rules you can follow to make an effective and good-looking table.

The basics

To start a table, place the code {|class="wikitable" on a new line. The {| defines a table, and the class="wikitable" styles it in the standard table style. To mark the end of a table, place |} at the bottom.

Regular cells in the table start with the | (vertical bar) character. To add a cell, just start a line with this character and add the text you want to appear after it. Adding no extra text will make the cell empty. Cells will go from left to right in the order you add them.

To start a new row of the table, place |- on its own line.

Here is an example of these basic table features.

Wiki code Result
{|class="wikitable"
|Cell 1
|Cell 2
|Cell 3
|-
|Cell 4
|Cell 5
|Cell 6
|}
Cell 1 Cell 2 Cell 3
Cell 4 Cell 5 Cell 6

Often, you want to make a cell a header cell. Header cells have a green background and bold text, and are commonly used on the top row and sometimes the left column of a table. To do this, replace the | with a !.

Wiki code Result
{|class="wikitable"
!
!Column 1
!Column 2
|-
!Row 1
|
|
|-
!Row 2
|
|
|}
Column 1 Column 2
Row 1
Row 2

To save space, instead of having each cell on its own line, you can use the vertical bar (or exclamation mark) character twice to start a new cell. This can make the wiki code harder to read, so only do this when there's a good reason to.

Wiki code Result
{|class="wikitable"
!Pikmin type !! Resistant to !! Attack power !! Throw height
|-
|[[Red Pikmin]] || Fire || 15 || Normal
|-
|[[Yellow Pikmin]] || Electricity || 10 || High
|-
|[[Blue Pikmin]] || Water || 10 || Normal
|}
Pikmin type Resistant to Attack power Throw height
Red Pikmin Fire 15 Normal
Yellow Pikmin Electricity 10 High
Blue Pikmin Water 10 Normal

Make sure that every row and column has the same number of cells. If you add an extra column to one row, make sure to do that for all rows, or weird empty spaces will appear in the table. Similarly, if you add a new row, make sure it has a cell for every column.

More advanced features

Additional properties can be added to cells, rows, and entire tables to change their appearance or functionality.

Let's start with the {|class="wikitable" at the start. More words can be added after wikitable to add more attributes to the table. Adding the text sortable allows each column to be sorted, which can be very useful, and additional attributes and options for each attribute are available. Here is an example of a sortable table.

Wiki code Result
{|class="wikitable sortable"
!Ship part
!Weight
|-
|Main Engine
|20
|-
|Eternal Fuel Dynamo
|40
|-
|Gravity Jumper
|25
|-
|Geiger Counter
|15
|-
|Gluon Drive
|50
|-
|Zirconium Rotor
|30
|}
Ship part Weight
Main Engine 20
Eternal Fuel Dynamo 40
Gravity Jumper 25
Geiger Counter 15
Gluon Drive 50
Zirconium Rotor 30

It's also possible to add attributes to cells, by placing the property text after the vertical bar or exclamation mark, and then placing another vertical bar before the actual cell content. The most useful attributes are colspan and rowspan, which allow a cell to take up multiple columns or rows. The style attribute can be used to change a cell's appearance with CSS. A demonstration of how to use these attributes is below.

Wiki code Result
{|class="wikitable"
!
!Column 1
!Column 2
!Column 3
|-
!Row 1
|colspan="2"|Long cell
|Regular cell
|-
!Row 2
|rowspan="2"|Tall cell
|colspan="2"|Long cell
|-
!Row 3
|Regular cell
|style="background-color:yellow"|Yellow cell
|}
Column 1 Column 2 Column 3
Row 1 Long cell Regular cell
Row 2 Tall cell Long cell
Row 3 Regular cell Yellow cell

Those are all the most useful features of tables on Pikipedia, though not all features are covered – a lot is possible with a table. If you're having trouble with a table, consider looking around the wiki for other tables and seeing what they do, looking at the official MediaWiki table guide, or asking for help on the Discord server.