Jump to content

Help:Introduction to tables with Wiki Markup/2

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Evolution and evolvability (talk | contribs) at 08:24, 6 December 2015 (new intro sentence). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Editing tables
The basics

Expanding tables
Adding rows and columns

Summary
Review of what you've learned


If you want more control over tables, you'll want to know how the formatting actually works.

The markup for a basic table is:

{| class="wikitable"
|-
! Header C1
! Header C2
! Header C3
|-
| R1C1
| R1C2
| R1C3
|-
| R2C1
| R2C2
| R2C3
|}

This would produce:

Header C1 Header C2 Header C3
R1C1 R1C2 R1C3
R2C1 R2C2 R2C3


As you can see, columns headers are created by ! column name. Cells are created by | cell text. The divider between rows is |-. You can add an extra column by just sticking ! new column name at the end of the last column name. To fill the cells in that column, you need to add another cell to each row: fill it by typing | cell text. If you want to add an extra row, just add |- to the table, and fill it with however many cells are appropriate.

To recap, the markup is:

{|

table start: required!

|+

table caption: optional. Only between table start and first table row

!

table header cell: optional. Consecutive cells may be added on same lines separated by double marks (!!); or start on new lines, each beginning with its own single mark (!).

|-

table row: optional on first row, otherwise required. The wiki engine assumes the first row.

|

table data cell: required! Consecutive cells may be added on same lines separated by double marks (||); or start on new lines, each beginning with its own single mark (|). Single marks are also used to separate HTML attributes from cell contents (both data or header), or caption contents.

|}

table end: required!
  • Blank spaces at the beginning of a line are ignored.
  • Escaping to insert a pipe (|) character into a table can be done using the <nowiki> markup.
  • class="wikitable" is used with a lot of tables on Wikipedia, and adds some standard formatting.


Using || and !! with tables

The above markup must start on a new line. This includes the cell markup (| and !). But the double cell markup (|| and !!) can optionally be used for adding consecutive cells to a single line.

For example, this would produce the same table as above:

{| class="wikitable"
|-
! Header C1 !! Header C2 !! Header C3
|-
| R1C1      || R1C2      || R1C3
|-
| R2C1      || R2C2      || R2C3
|}