Help:Wikitable
Appearance
A wikitable is an arrangement of columns and rows used to organize and position data. Tables are useful, and there are many ways and tricks that can be used.
When editing pages a generic wikitable can be added with the (Insert a table) link in the edit toolbar. The following text is inserted when "Insert a table" is clicked:
{| class="wikitable" |- ! header 1 ! header 2 ! header 3 |- | row 1, cell 1 | row 1, cell 2 | row 1, cell 3 |- | row 2, cell 1 | row 2, cell 2 | row 2, cell 3 |} |
|
The sample text ("header 1", "row 1, cell 1" etc) is to be replaced with actual data.
Wiki table markup summary
{| |
table start |
|+ |
table caption, optional; only between table start and first table row |
|- |
table row, optional on first row -- wiki engine assumes the first row |
! |
table header cell, optional. Consecutive table header cells may be added on same line separated by double marks (!! ) or start on new lines, each with its own single mark (! ).
|
| |
table data cell, required! Consecutive table data cells may be added on same line separated by double marks (|| ) or start on new lines, each with its own single mark (| ).
|
|} |
table end |
- The above marks must start on a new line except the double
||
and!!
for optionally adding consecutive cells to a line. However, blank spaces at the beginning of a line are ignored. - XHTML attributes. Each mark, except table end, optionally accepts one or more XHTML attributes. Attributes must be on the same line as the mark. Separate attributes from each other with a single space.
- Cells and caption (
|
or||
,!
or!!
, and|+
) hold content. So separate any attributes from content with a single pipe (|
). Cell content may follow on same line or on following lines. - Table and row marks (
{|
and|-
) do not directly hold content. Do not add pipe (|
) after their optional attributes. If you erroneously add a pipe after attributes for the table mark or row mark the parser will delete it and your final attribute if it was touching the erroneous pipe!
- Cells and caption (
- Content may (a) follow its cell mark on the same line after any optional XHTML attributes or (b) on lines below the cell mark. Content that uses wiki markup that itself needs to start on a new line, such as lists, headings, or nested tables, must be on its own new line.
- Escaping to insert a pipe (
|
) character into a table use the <nowiki> markup
Examples
A simple table:
{| | A simple table |}
What it looks like in your browser:
A simple table |
A more complex example:
{| border="1" cellpadding="5" cellspacing="0" align="center" |+ '''An example table''' |- ! style="background-color: #efefef;" | First header ! colspan="2" style="background-color: #ffdead;" | Second header |- | upper left | | rowspan="2" style="border-bottom: 3px solid grey;" valign="top" | right side |- | style="border-bottom: 3px solid grey;" | lower left | style="border-bottom: 3px solid grey;" | lower middle |- | colspan="3" align="center" | {| border="0" |+ ''A table in a table'' |- | align="center" width="150" | [[File:Wiki.png]] | align="center" width="150" | [[File:Wiki.png]] |- | align="center" colspan="2" style="border-top: 1px solid red;<!-- --> border-right: 1px solid red; border-bottom:2px solid red;<!-- --> border-left: 1px solid red;" | Two Wikimedia logos |} |} </nowiki>
What it looks like in your browser:
An example table First header Second header upper left right side
lower left lower middle
A table in a table ![]()
![]()
Two Wikimedia logos