Help:Table markup
From ChinaTravelGuide
Although HTML table syntax also works, special wikicode can be used as a shortcut to create a table. The pipe (vertical bar) codes function exactly the same as HTML table markup.
Contents |
[edit] Table
Below is the wiki syntax for a typical table:
{| class="wikitable"
|+ Caption Here
|-
! 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
|}
And here is the table after rendered:
| 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 |
Instead of params, you can put any parameters you choose that would normally go into a HTML table.
- Careful: You must include the space between {| and params, or the first parameter gets ignored.
[edit] Caption
The caption is generated by:
|+ Caption Here
The caption must go on its own line to be recognized by the wiki parser engine.
[edit] Row
A row of cells is started like this:
|-
The code must be on its own line, and serves the same purpose as the TR tags.
[edit] Header
A header cell is created like this:
! header 1
Each cell must go on its own line. This takes the place of the TH tag. If you want to assign parameters to your cell, they will go like this:
! params | header 1
Make sure to have a space between the pipe and the parameters!
[edit] Cell
Normal table cells (TD) are created like this:
| row 1, cell 1
These are similar to header cells, except they use the pipe character instead of an exclamation point. Again, each cell must go on its own line. If you want to assign parameters to a cell, they go between two pipes (see below example):
| params | row 1, cell 1
[edit] Example
The following is another example combines all of the previous elements:
{| class="grey"
|+ Caption Here
|-
! 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
|-
| colspan="2" | Row 3, Cols 1-2
| Row 3, Col 3
|}
And here is the table in its processed form:
| 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 |
| Row 3, Cols 1-2 | Row 3, Col 3 | |
Also see Formatting Tables] – Provides more detailed instructions and advanced tricks for compressing the wiki format

