Jump to content

Help:Wikitable

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Gadget850 (talk | contribs) at 20:00, 9 February 2013 (→‎Markup: ce). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

A table 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.

The edit toolbar is shown above the editing window (Vector toolbar - default).
Monobook toolbar

Adding a table

When editing pages a generic table can be added with the or (Insert a table) link in the edit toolbar. The following markup is inserted when "Insert a table" is clicked:

{| class="wikitable"
|-
! Header text !! Header text !! Header text
|-
| Example || Example || Example
|-
| Example || Example || Example
|-
| Example || Example || Example
|}

Markup

{|
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 markup 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.
  • HTML attributes: All table markup, except table end, optionally accepts one or more HTML attributes on the same line.
    • 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 markup ({| 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 or row markup, the parser will delete it and any final attribute that was touching the improper pipe.
  • Content may follow its cell mark on the same line after any optional HTML attributes or 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
  • Classes
    • class="wikitable sortable"
    • class="wikitable plainrowheaders"

Examples

A simple table

Template:Multicol

{|
| A simple table
|}

Template:Multicol-break

A simple table

Template:Multicol-end

More complex examples

Template:Multicol

{| 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
|-

! scope="row" | Header row 5
|cell R4-A
|cell R4-B
|cell R4-C
|cell R4-D
|}

Template:Multicol-break

Table caption
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
Header row 5 cell R4-A cell R4-B cell R4-C cell R4-D

Template:Multicol-end

Template:Multicol

{|  border="1" style=" border-spacing: 5"
|-
! scope="col" | Heading for column 1
! scope="col" | Heading for column 2
! scope="col" | Heading for column 3
|-
|text for row 1, column 1
|text for row 1, column 2
|text for row 1, column 3
|-
|text for row 2, column 1
|text for row 2, column 2
|text for row 2, column 3
|}

Template:Multicol-break

Heading for column 1 Heading for column 2 Heading for column 3
text for row 1, column 1 text for row 1, column 2 text for row 1, column 3
text for row 2, column 1 text for row 2, column 2 text for row 2, column 3

Template:Multicol-end

Template:Multicol

{|  border="1" style="border-spacing: 5; padding: 0"
|-
! scope="col" | Heading for column 1
! scope="col" | Heading for column 2
! scope="col" | Heading for column 3
|-
|text for row 1, column 1
|text for row 1, column 2
|text for row 1, column 3
|-
|text for row 2, column 1
|text for row 2, column 2
|text for row 2, column 3
|}

Template:Multicol-break

Heading for column 1 Heading for column 2 Heading for column 3
text for row 1, column 1 text for row 1, column 2 text for row 1, column 3
text for row 2, column 1 text for row 2, column 2 text for row 2, column 3

Template:Multicol-end

Template:Multicol

{|  border="1" style="border-spacing: 5; padding: 0"
|-
! scope="col" style="background:#efefef;" | Heading for column 1
! scope="col" style="background:#efefef;" | Heading for column 2
! scope="col" style="background:#efefef;" | Heading for column 3
|-
|text for row 1, column 1
|text for row 1, column 2
|text for row 1, column 3
|-
|text for row 2, column 1
|text for row 2, column 2
|text for row 2, column 3
|}

Template:Multicol-break

Heading for column 1 Heading for column 2 Heading for column 3
text for row 1, column 1 text for row 1, column 2 text for row 1, column 3
text for row 2, column 1 text for row 2, column 2 text for row 2, column 3

Template:Multicol-end

Template:Multicol

{|  border="1" style="border-spacing: 5; padding: 0"
|-
|
! scope="col" style="background:#efefef;" | Heading for column 1
! scope="col" style="background:#efefef;" | Heading for column 2
! scope="col" style="background:#efefef;" | Heading for column 3
|-
! scope="row" style="background:#efefef;" | Heading for row 1
|text for row 1, column 1
|text for row 1, column 2
|text for row 1, column 3
|-
! scope="row" style="background:#efefef;" | Heading for row 2
|text for row 2, column 1
|text for row 2, column 2
|text for row 2, column 3
|}

Template:Multicol-break

Heading for column 1 Heading for column 2 Heading for column 3
Heading for row 1 text for row 1, column 1 text for row 1, column 2 text for row 1, column 3
Heading for row 2 text for row 2, column 1 text for row 2, column 2 text for row 2, column 3

Template:Multicol-end

See also