MediaWiki User Guide: Using tables

From NWN1 Custom Content Guide

Jump to: navigation, search

<- MediaWiki User Guide

This new table markup, developed by Magnus Manske, replaces the <table>, <tr>, <td>, <th>, and <caption> HTML tags. The HTML tags can still be used though.

The tags below must start at the beginning of a new line (with one exception). The parameters are optional.

See also: Wiki markup tables, WikiShouldOfferSimplifiedUseOfTables, Wikipedia:How to use tables


Contents

Table

A table is defined by

which equals

<table params>
</table>
Careful: You must include the space between {| and params, or the first parameter gets ignored.

TD

Cells are generated either like this:

|cell1
|cell2
|cell3

or like this:

|cell1||cell2||cell3

which both equals

<td>cell1</td><td>cell2</td><td>cell3</td>

so "||" equals "newline"+"|"

Parameters in cells can be used like this:

|params|cell1

which will result in

<td params>

TH

Functions the same way as TD, except "!" is used instead the opening "|". "!!" can be used instead of "||". Parameters still use "|", though!

TR

<tr> tags will be generated automatically for the first row. To start a new row, use

|-

which results in

<tr>

Parameters can be added like this:

|- params

which results in

<tr params>

Note:

  • <tr> tags will be automatically opened at the first <td> equivalent
  • <tr> tags will be automatically closed at <tr> and </table> equivalents

CAPTION

A <caption> tag is created by

|+ Caption

which generates

<caption>Caption</caption>

You can also use parameters:

|+ params|Caption

which will generate

<caption params>Caption


Examples

Simple example

Cell 1, row 1 Cell 2, row 1
Cell 1, row 2 Cell 2, row 2

generates

Cell 1, row 1 Cell 2, row 1
Cell 1, row 2 Cell 2, row 2


Advanced example

Cell 1, row 1 Cell 2, row 1 (and 2) Cell 3, row 1
Cell 1, row 2 Cell 3, row 2

Note the floating table to the right.

Cell 1, row 1 Cell 2, row 1 (and 2) Cell 3, row 1
Cell 1, row 2 Cell 3, row 2

Nested table

blabla
nested
table
the original table again

gives a nested table

blabla
nested
table
the original table again

Caption and multi-cell-lines

This is the caption. Example taken from Afghanistan table.
IndependenceAugust 19, 1919
CurrencyAfghani
Time zoneUTC+4:30
National anthemSououd-e-Melli
Internet TLD.AF
{| border=1 align=right
|+ '''This is the caption.''' Example taken from Afghanistan table.
|[[Independence]]||[[August 19]], [[1919]]
|-
|[[Currency]]||[[Afghani]]
|-
|[[Time zone]]||[[UTC]]+4:30
|-
|[[National anthem]]||[[Sououd-e-Melli]]
|-
|[[Top-level domain|Internet TLD]]||.AF
|}

is shown on the right.


Header test

Header1 Header2
Cell1 Cell2

made by

Header1 Header2
Cell1 Cell2


TR test

cell1 cell2
cell3 cell4

makes

cell1 cell2
cell3 cell4

Test for rows with mixed headers and body text

col Header1 ch2
row header 3 abc def ghi gchf ghh dfgh
RH 4 gfbb gbgbds dfgsdsdg

makes:

col Header1 ch2
row header 3 abc def ghi gchf ghh dfgh
RH 4 gfbb gbgbds dfgsdsdg

but:

&nbsp; col Header1 ch2
row header 3 abc def ghi gchf ghh dfgh
RH 4 gfbb gbgbds dfgsdsdg
RH 5

makes:

  col Header1 ch2
row header 3 abc def ghi gchf ghh dfgh
RH 4 gfbb gbgbds dfgsdsdg
RH 5
Personal tools