Beruflich Dokumente
Kultur Dokumente
Wikitext
Cheatsheet
All Wikitext
Magic links
Visual files
Sound files
Tables
Using templates
v
t
e
A table is an arrangement of columns and rows that organizes and positions data. Tables can
be created on Wikipedia pages using special wikitext syntax, and many different styles and
tricks can be used to customise them.
Tables can be used as formatting instrument, but consider using a multi column listinstead.
Contents
Monobook toolbar
To automatically insert a table, click or (Insert a table) on the edit toolbar. If "Insert a
table" is not on the toolbar follow these directions to add it.
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 N" or "row N, cell N") is intended to be replaced with actual data.
Optional.
|+
Table
caption Only between table start and first table row.
Optional.
|- Table row
Can be omitted before the first row.
Optional.
!
Table Consecutive table header cells may be added on same line separated by double marks ( !! ); or start on
header cell
lines, each with its own single mark ( ! ).
Optional.
Table data Consecutive table data cells may be added on same line separated by double marks ( || ) or start on new
|
cell each with its own single mark ( | ). This mark is also used to separate HTML attributes from cell and ca
contents.
|} Table end Required.
The above marks must start on a new line, except the double marks ( || and !! ) for
optionally adding consecutive cells to a single line.
Content may either 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 with lists, headings, or nested tables, must be on its own
new line.
Table and row marks ( {| and |- ) do not directly hold content. Do not add a pipe ( | )
after any attributes.
Commonly included attributes in tables include: class , for
example class="wikitable" ; style , for CSS styling; scope , to indicate row or column
header cells; rowspan , to extend cells by more than one row; colspan , to extend cells by
more than one column; and border , for borders for non-wikitable tables.
The entire table is encased with curly brackets and a vertical bar character (a pipe). So
use {| to begin a table, and |} to end it. Each one needs to be on its own line:
{|
table code goes here
|}
An optional table caption is included with a line starting with a vertical bar and plus sign
" |+ " and the caption after it:
{|
|+ caption
table code goes here
|}
To start a new table row, type a vertical bar and a hyphen on its own line: " |- ". The
codes for the cells in that row start on the next line.
{|
|+ The table's caption
|-
row code goes here
|-
next row code goes here
|}
Type the codes for each table cell in the next row, starting with a bar:
{|
|+ The table's caption
|-
| cell code goes here
|-
| next row cell code goes here
| next cell code goes here
|}
Cells can be separated with either a new line and a single bar, a new line and a double
bar, or by a double bar " || " on the same line. All three produce the same output:
{|
|+ The table's caption
|-
|Cell 1 || Cell 2 || Cell 3
|-
|Cell A
|Cell B
|Cell C
|}
A row of column headers is identified by using " ! scope="col" | " instead of " | ", and
using " !! scope="col" | " instead of " || ". Header cells typically render differently from
regular cells, depending on the browser. They are often rendered in a bold font and
centered. The scope="col" markup is not technically necessary in wikitables styled with
class markup: class="wikitable" and so on. However, it is easier for other editors to
understand the markup when it is present, and the Manual of Style recommends using
it because it directly associates header with corresponding cells, a boon to accessibility.
{|
|+ The table's caption
! scope="col" | Column header 1
! scope="col" | Column header 2
! scope="col" | Column header 3
|-
| Cell 1 || Cell 2 || Cell 3
|-
| Cell A
| Cell B
| Cell C
|}
The first cell of a row is identified as a row header by starting the line with " !
scope="row" | " instead of " | ", and starting subsequent data cells on a new line.
The scope="row" code, as with scope="col" , is not technically required in wikitables
styled with class markup like class="wikitable" , but it is recommended by the Manual
of Style for both accessibility and code readability reasons.
{|
|+ The table's caption
! scope="col" | Column header 1
! scope="col" | Column header 2
! scope="col" | Column header 3
|-
! scope="row" | Row header 1
| Cell 2 || Cell 3
|-
! scope="row" | Row header A
| Cell B
| Cell C
|}
Optional parameters can modify the display and styling of cells, rows, or the entire table.
The simplest way to add styling is to set the wikitable CSS class, which in
Wikipedia's external style sheet is defined to apply a gray color scheme and cell borders to
tables using it:
{| class="wikitable"
|+ The table's caption
! Column header 1
! Column header 2
! Column header 3
|-
! Row header 1
| Cell 2 || Cell 3
|-
! Row header A
| Cell B
| Cell C
|}
The table parameters and cell parameters are the same as in HTML,
see http://www.w3.org/TR/html401/struct/tables.html#edef-TABLE and Table (HTML).
However, the thead , tbody , tfoot , colgroup , and col elements are currently not
supported in MediaWiki, as of April 2017.
A table can be useful even if none of the cells have content. For example, the background
colors of cells can be changed with cell parameters, making the table into a diagram,
like meta:Template talk:Square 8x8 pentomino example. An "image" in the form of a table is
much more convenient to edit than an uploaded image.
Each row must have the same number of cells as the other rows, so that the number of
columns in the table remains consistent. For empty cells, use the non-breaking
space as content to ensure that the cells are displayed.
With colspan and rowspan cells can span several columns or rows; (See § Mélange,
below.)
Rendering the pipe[edit]
When cell content that contains a pipe character does not render correctly, simply add an
empty format for that cell. The second pipe character in a line of |cell code will not display;
it is reserved for adding a format. Wikicode between the first and second pipe is a format, but
since emptiness or an error there is ignored, it just disappears. When this happens add a
dummy format. (For a real format, see § HTML attributes, below.) Use a third pipe character to
render your first pipe character.
Rendering the first pipe when it is the third pipe in the cell code
Code Rendering
Code Rendering
{| class="wikitable" |Pipes34:||
|-
|<nowiki>|</nowiki>Pipes34:<nowiki>||</nowiki>
|Pipes34:||
|-
||Pipes34:||
|}
Template {{!}} , because of the order in which things are parsed, is equivalent to typing in a
single | pipe character. The single <nowiki />| parser-tag does not apply here. See how
they do not escape the second pipe, as | and <nowiki>|</nowiki> did above:
Code Rendering
{| class="wikitable" Pipe3:|
|-
|<nowiki />|Pipe3:|
Pipe3:|
|-
|Pipe2:{{!}}Pipe3:{{!}}
|}
Examples[edit]
Simple straightforward tables[edit]
Minimalist table[edit]
Both of these generate the same output. Choose a style based on the number of cells in each
row and the total text inside each cell.
Wiki markup:
{|
|-
| A
| B
|-
| C
| D
|}
{|
|-
| A || B
|-
| C || D
|}
As it appears in a browser:
Multiplication table
× 1 2 3
1 1 2 3
2 2 4 6
3 3 6 9
4 4 8 12
5 5 10 15
{| class="wikitable"
|+ style="text-align: left;" | Data reported for 2014–2015, by region<ref
name="Garcia 2005" />
|-
! scope="col" | Year !! scope="col" | Africa !! scope="col" | Americas !!
scope="col" | Asia & Pacific !! scope="col" | Europe
|-
! scope="row" | 2014
| 2,300 || 8,950 || ''9,325'' || 4,200
|-
! scope="row" | 2015
| 2,725 || ''9,200'' || 8,850 || 4,775
|}
As it appears in a browser:
Width, height[edit]
The width and height of the whole table can be specified, as well as the height of a row. To
specify the width of a column one can specify the width of an arbitrary cell in it. If the width is
not specified for all columns, and/or the height is not specified for all rows, then there is some
ambiguity, and the result depends on the browser.
Wiki markup:
As it appears in a browser:
Setting borders[edit]
Add a border around a table using the CSS property border: thickness style color; ,
for example border:3px dashed red . This example uses a solid (non-dashed) gray border
that is one pixel wide:
Wiki markup:
Note the bottom-row texts are centered by style="text-align: center;" while the star
images are not centered (i.e. left aligned).
As long as the File: specs omit the parameter |thumb they don't show the caption lines in
the table (only during mouse-over). The border color darkgray matches typical tables or
infoboxes in articles; however, it could be any color name (as in style="border: 1px
solid darkgreen;" ) or use a hex-color (such as: #DDCCBB ).
The same CSS can be used in a cell's format specifier (enclosed in | ... | ) to put a border
around each cell:
Wiki markup:
{| border=1
|-
| A || B || C
|-
| D || E || F
|}
A B C
D E F
Using the border-collapse property to combine the double borders, as described above:
ABC
DE F
Positioning[edit]
You can position the entire table, the contents of a row, and the contents of a cell, but not
with a single parameter for all the contents of the table. See m:Template talk:Table demo.
Prior to April 2009, using float to position a table was discouraged; however, it no
longer always breaks page rendering at large font sizes. See a floated image, below,
under "Floating images in the center".
Side by side tables[edit]
You can also place tables side by side by adding style="display: inline-
table;" to the opening of your table. The tables will wrap depending on screen width.
Narrow your browser window to see. For example:
Gets:
Table 1
Name Color
Fred Orange
Bob Green
Lindy Yellow
Table 2
Animal State
Racoon Maine
Whale Alaska
Table 1
Name Color
Fred Orange
Bob Green
Lindy Yellow
Table 2
Animal State
Racoon Maine
Whale Alaska
Floating table[edit]
Two table classes floatleft and floatright (case sensitive) help floating the table and
adjusting table margins so that they do not stick to the text. floatleft floats the table to the
left and adjusts right margin. floatright does the opposite. Example:
This paragraph is before the table. The text in column 2 spans both rows
because of format specifier "rowspan=2" so there is no coding for "Col 2"
in the 2nd row, just Col 1 and Col 3.
{| class="wikitable floatright"
| Col 1, row 1
| rowspan="2" | Col 2, row 1 (and 2)
| Col 3, row 1
|-
| Col 1, row 2
| Col 3, row 2
|}
{| class="wikitable floatleft"
| Col 1, row 1
| rowspan="2" | Col 2, row 1 (and 2)
| Col 3, row 1
|-
| Col 1, row 2
| Col 3, row 2
|}
Sed ut perspiciatis, unde omnis iste natus error sit voluptatem
accusantium doloremque laudantium, totam rem aperiam eaque ipsa, quae ab
illo inventore veritatis et quasi architecto beatae vitae dicta sunt,
explicabo. Nemo enim ipsam voluptatem, quia voluptas sit, aspernatur aut
odit aut fugit, sed quia consequuntur magni dolores eos, qui ratione
voluptatem sequi nesciunt, neque porro quisquam est, qui dolorem ipsum,
quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam
eius modi tempora incidunt, ut labore et dolore magnam aliquam quaerat
voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam
corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur?
Quis autem vel eum iure reprehenderit, qui in ea voluptate velit esse,
quam nihil molestiae consequatur, vel illum, qui dolorem eum fugiat, quo
voluptas nulla pariatur?
As it appears in a browser:
This paragraph is before the table. The text in column 2 spans both rows because of format
specifier "rowspan=2" so there is no coding for "Col 2" in the 2nd row, just Col 1 and Col 3.
Sed ut perspiciatis, unde omnis iste natus error sit voluptatem accusantium doloremque
laudantium, totam rem aperiam eaque ipsa, quae ab illo inventore veritatis et quasi architecto
beatae vitae dicta sunt, explicabo. Nemo enim ipsam voluptatem, quia voluptas sit, aspernatur
aut odit aut fugit, sed quia consequuntur magni dolores eos, qui ratione voluptatem sequi
nesciunt, neque porro quisquam est, qui dolorem ipsum, quia dolor sit amet, consectetur, adipisci
velit, sed quia non numquam eius modi tempora incidunt, ut labore et dolore magnam aliquam
quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis
suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure
reprehenderit, qui in ea voluptate velit esse, quam nihil molestiae consequatur, vel illum, qui
dolorem eum fugiat, quo voluptas nulla pariatur?
Note that although there are other ways to float a table, such
as style="float:left;" , style="float:right;" , the only parameters that allow you to
position the table under a floated multimedia object are floatleft and floatright . For
example:
Aligning the table with floatleft produces:
Sed ut perspiciatis, unde omnis iste natus error sit voluptatem accusantium doloremque
laudantium, totam rem aperiam eaque ipsa, quae ab illo inventore veritatis et quasi architecto
beatae vitae dicta sunt, explicabo. Nemo enim ipsam voluptatem, quia voluptas sit, aspernatur
aut odit aut fugit, sed quia consequuntur magni dolores eos, qui ratione voluptatem sequi
nesciunt, neque porro quisquam est, qui dolorem ipsum, quia dolor sit amet, consectetur, adipisci
velit, sed quia non numquam eius modi tempora incidunt, ut labore et dolore magnam aliquam
quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis
suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure
reprehenderit, qui in ea voluptate velit esse, quam nihil molestiae consequatur, vel illum, qui
dolorem eum fugiat, quo voluptas nulla pariatur?
But aligning it with style="float:left;" produces:
Sed ut perspiciatis, unde omnis iste natus error sit voluptatem accusantium doloremque
laudantium, totam rem aperiam eaque ipsa, quae ab illo inventore veritatis et quasi architecto
beatae vitae dicta sunt, explicabo. Nemo enim ipsam voluptatem, quia voluptas sit, aspernatur
aut odit aut fugit, sed quia consequuntur magni dolores eos, qui ratione voluptatem sequi
nesciunt, neque porro quisquam est, qui dolorem ipsum, quia dolor sit amet, consectetur, adipisci
velit, sed quia non numquam eius modi tempora incidunt, ut labore et dolore magnam aliquam
quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis
suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure
reprehenderit, qui in ea voluptate velit esse, quam nihil molestiae consequatur, vel illum, qui
dolorem eum fugiat, quo voluptas nulla pariatur?
Centering tables[edit]
Shortcut
HELP:TABLECENTER
Centered tables can be achieved, but they don't "float"; that is to say, no text appears to either
side. The trick is
{| style="margin-left: auto; margin-right: auto; border: none;" [1]
Wiki markup:
As it appears in a browser:
Text before table...
As it appears in a browser:
t
h
e
cel o
l2 r
i
N g
E i
S n
T a A C
αE l
D t B B D
T a
A b
B l
L e
E a
g
a
i
n
Scrolling[edit]
The whole table can be placed within a scrolling list so that new table lines appear on the
screen as old table lines disappear. Although MOS:SCROLL disfavors scrolling tables in article
space because article content should be accessible on a variety of devices whereas a scrolling
table hides some text, a scrolling table may be used in other Wikipedia namespaces.
Wiki markup:
<div style="width: 75%; height: 10em; overflow: auto; border: 2px solid
red;">
{| class="wikitable"
|-
| abc || def || ghi
|- style="height: 100px;"
| jkl || style="width: 200px;" | mno || pqr
|-
| stu || vwx || yz
|}
</div>
As it appears in a browser:
stu vwx yz
{|
|-
| style="background: red; color: white;" | abc
| def
| style="background: red;"| <span style="color: white;"> ghi </span>
| jkl
|}
As it appears in a browser:
abc def ghi jkl
Like other parameters, colors can also be specified for a whole row or the whole table;
parameters for a row override the value for the table, and those for a cell override those for a
row. (Note that there is no easy way to specify a color for a whole column—each cell in the
column must be individually specified. Tools can make it easier.)
Wiki markup:
As it appears in a browser:
stu vwx yz
stu vwx yz
stu vwx yz
Cell operations[edit]
Setting cell parameters[edit]
At the start of a cell, add your parameter followed by a single pipe. For
example, style="width: 300px"| sets that cell to a width of 300 pixels. To set more than
one parameter, leave a space between each one.
Wiki markup:
{| style="color: white;"
|-
| style="background: red;"|cell1 || style="width: 300px; background:
blue;"|cell2
| style="background: green;"|cell3
|}
As it appears in a browser:
cell1 cell2 cell3
Vertical alignment in cells[edit]
By default, text is aligned to the vertical middle of the cell:
To align the text to the top of the cell, apply the style="vertical-align: top;" CSS to
the rows (unfortunately, it seems to be necessary to apply this individually to every single row).
The valign=... attribute is obsolete and should not be used.
Wiki markup:
{| class="wikitable"
|-
| Cell content that is not indented || 1
|-
| style="padding-left: 2em;" | Indented content || 2
|}
Indented content 2
Row operations[edit]
Height[edit]
(See § Width, height, above.)
Border[edit]
(See § Setting borders, above.)
Alignment[edit]
(See § Positioning, above.)
Indexing[edit]
Main page: Template:Row indexer
Column operations[edit]
Setting column widths[edit]
To force column widths to specific requirements, rather than accepting the width of the widest
text element in a column's cells, follow this example. Note that wrap-around of text is forced.
Wiki markup:
{| class="wikitable"
! scope="col" style="width: 50px;" | Name
! scope="col" style="width: 250px;" | Effect
! scope="col" style="width: 225px;" | Games found in
|-
| Poké Ball || Regular Poké Ball || All versions
|-
| Great Ball || Better than a Poké Ball || All versions
|}
To set column widths in a table without headers, specify the width in the first cell for each
column.
Wiki markup:
{| class="wikitable"
|-
| style="width: 100pt;" | This column is 100 points wide
| style="width: 200pt;" | This column is 200 points wide
| style="width: 300pt;" | This column is 300 points wide
|-
| blah || blih || bluh
|}
This column is
This column is 200 points wide This column is 300 points wide
100 points wide
You can also use percentages, such as to equalize the widths of a two-column table by setting
one of them to style="width: 50%;" .
One application of setting the widths is aligning columns of consecutive tables. The following
are separate tables, with columns set to 350px and 225px. Warning: Setting specific pixel sizes
is deprecated, as it interferes with the ability of the browser to adjust content to suit the browser
window, device size, user-end font size limits, and other constraints. It is strongly preferred to
use relative sizes, in percentage or em values.
Country Capital
Country Capital
France Paris
Nowrap[edit]
In a table that spans the entire width of a page, cells narrower than the widest cell tend to
wrap. To keep an entire column from wrapping, use style="white-space: nowrap;" in a
non-header cell on the longest/widest cell to affect the entire column.
Without nowrap , as it appears in a browser:
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
"The Journey January
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
Begins" 1, 2010
velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est
laborum.
Episode Date Summary
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
"When veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
January
Episodes commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
8, 2010
Attack" velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est
laborum.
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
January
"So Long" commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
15, 2010
velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est
laborum.
With nowrap , on both the Episode and Date columns, as it appears in a browser:
Tooltips[edit]
You can add tooltips to columns by using the {{H:title}} template. Simply replace the column-
title with {{H:title|The tool tip|Column title}} , which makes it appear like
so: Column title.
More complex examples[edit]
Mélange[edit]
Note: This example is not accessible, and should be avoided as much as possible. For
example, nested tables (tables inside tables) should be separated into distinct tables when
possible.
Here is a more advanced example, showing some more options available for making up tables.
Users can play with these settings in their own table to see what effect they have. Not all of
these techniques may be appropriate in all cases; just because colored backgrounds can be
added, for example, does not mean it is always a good idea. Try to keep the markup in tables
relatively simple—remember, other people are going to be editing the article too! This example
should give an idea of what is possible, though.
Wiki markup:
As it appears in a browser:
Text before centered table...
An example table
Right side
Upper left Upper middle