Help:Wikitable
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 or (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
edit
{| |
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 a pipe is added improperly after attributes for the table mark or row mark, the parser will delete it and any final attribute that was touching the improper 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
editA simple table
edit{| | A simple table |}
As it appears in a browser:
A simple table |
A more complex example
edit{| class="wikitable" style="text-align:center; width:80%;" |+ Table caption |- | ! scope="col" | Header col. A ! scope="col" | Header col. B ! scope="col" | Header col. C ! scope="col" | Header col. D |- ! scope="row" | Header row 1 |cell R1-A |cell R1-B |cell R1-C |cell R1-D |- ! scope="row" | Header row 2 |cell R2-A |cell R2-B |cell R2-C |cell R2-D |- ! scope="row" | Header row 3 |cell R3-A |cell R3-B |cell R3-C |cell R3-D |- ! scope="row" | Header row 4 |cell R4-A |cell R4-B |cell R4-C |cell R4-D |}
As it appears in a browser:
Header col. A | Header col. B | Header col. C | Header col. D | |
---|---|---|---|---|
Header row 1 | cell R1-A | cell R1-B | cell R1-C | cell R1-D |
Header row 2 | cell R2-A | cell R2-B | cell R2-C | cell R2-D |
Header row 3 | cell R3-A | cell R3-B | cell R3-C | cell R3-D |
Header row 4 | cell R4-A | cell R4-B | cell R4-C | cell R4-D |