Help:Table: Difference between revisions

From Meta, a Wikimedia project coordination wiki
Content deleted Content added
→‎Vertical alignment: the use of "valign" is not recommended!
m Reverted changes by 180.249.186.24 (talk) to last version by Pols12
Tag: Rollback
 
(11 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{MovedToMediaWiki}}
<languages />
{{H:h|editor toc}}
<translate>
This page gives you information about syntax to build wiki-tables in [[w:MediaWiki|MediaWiki]]. You can also use VisualEditor for tables, with the option of copying the cells of any spreadsheet (e.g. Excel) and paste them into the editing area. ([[w:Help:Introduction to tables with VisualEditor/1|see how use VisualEditor for tables]]).

== Spreadsheet to wiki table format ==
To convert from spreadsheets such as Gnumeric, MS Excel or OpenOffice.org Calc, see <tvar name="1">https://excel2wiki.toolforge.org/</tvar>.

== Using the toolbar ==
</translate>
[[File:Toolbar2.JPG]]
<translate>
You can use the [[W:Wikipedia:Toolbars#MediaWiki Edit Toolbar|Mediawiki edit toolbar]] to create tables on Wikipedia, and some Wikimedia projects. It is helpful to generate the necessary codings. However, on many MediaWiki wikis (and by default) the table tool is not available.

Use the first button on the right of the toolbar to insert a table when editing a page.

By default, it includes the following text:
</translate>
{|class="wikitable"
|-
! <translate>Code</translate>
! <translate>Result</translate>
|-
|
<pre>
{| class="wikitable"
|-
! <translate nowrap>Header 1</translate>
! <translate nowrap>Header 2</translate>
! <translate nowrap>Header 3</translate>
|-
| <translate nowrap>row 1, cell 1</translate>
| <translate nowrap>row 1, cell 2</translate>
| <translate nowrap>row 1, cell 3</translate>
|-
| <translate nowrap>row 2, cell 1</translate>
| <translate nowrap>row 2, cell 2</translate>
| <translate nowrap>row 2, cell 3</translate>
|}
</pre>
|
{| class="wikitable"
|-
! <translate>Header 1</translate>
! <translate>Header 2</translate>
! <translate>Header 3</translate>
|-
| <translate>row 1, cell 1</translate>
| <translate>row 1, cell 2</translate>
| <translate>row 1, cell 3</translate>
|-
| <translate>row 2, cell 1</translate>
| <translate>row 2, cell 2</translate>
| <translate>row 2, cell 3</translate>
|}
|}
{{anchor|Pipe syntax tutorial}}<!-- This was the old title of the next section -->
<translate>
== Using the code – step-by-step tutorial ==
:''See also: [[<tvar name="1">#Pipe syntax in terms of the HTML produced</tvar>|Pipe syntax in terms of the HTML produced]]''
</translate>
{| class="wikitable"
! <translate>Column heading 1</translate> !! <translate>Column heading 2</translate> !! <translate>Column heading 3</translate>
|-
! <translate>Row heading A</translate>
| <translate>Cell A2</translate> || <translate>Cell A3</translate>
|-
! <translate>Row heading B</translate>
| <translate>Cell B2</translate>
| <translate>Cell B3</translate>
|}
<translate>
Although HTML table syntax also works, special MediaWiki code can be used as a shortcut to create a table. Formatting codes function the same as in [[w:HTML element#Tables|HTML table]] markup. The shortcuts are as follows:
</translate>
* <translate>The '''entire table''' is encased with curly brackets and a [[w:vertical bar|vertical bar]] character (a pipe). So use <tvar name="1"><code>{|</code></tvar> to begin a table, and <tvar name="2"><code>|}</code></tvar> to end it. Each one needs to be on its own line:</translate>
<span style="font-weight:bold; color:red"><nowiki>{|</nowiki></span>
''<translate>table code goes here</translate>''
<span style="font-weight:bold; color:red"><nowiki>|}</nowiki></span>
* <translate>An optional '''[[<tvar name="1">Special:MyLanguage/Help:Table caption</tvar>|table caption]]''' is included with a line starting with a vertical bar and plus sign <tvar name="2"><code>|+</code></tvar> and the caption after it:</translate>
<nowiki>{|</nowiki>
<span style="font-weight:bold; color:red"><nowiki>|+</nowiki> <translate>caption</translate></span>
''<translate>table code goes here</translate>''
<nowiki>|}</nowiki>
* <translate>To start a new '''table [[w:Row (database)|row]]''', type a vertical bar and a [[w:hyphen|hyphen]] on its own line: <tvar name="1"><code>|-</code></tvar>. The codes for the cells in that row will start on the next line.</translate>
<nowiki>{|</nowiki>
<nowiki>|+</nowiki> <translate>The table's caption</translate>
<span style="font-weight:bold; color:red"><nowiki>|-</nowiki></span>
''<translate>cell code goes here (first row)</translate>''
<span style="font-weight:bold; color:red"><nowiki>|-</nowiki></span>
''<translate>cell code goes here (second row)</translate>''
<nowiki>|}</nowiki>
* <translate>Type the codes for each '''table [[w:Table (database)|cell]]''' in the next row, starting with a bar:</translate>
<nowiki>{|</nowiki>
<nowiki>|+</nowiki> <translate>The table's caption</translate>
<nowiki>|-</nowiki>
<span style="font-weight:bold; color:red">|</span> ''<translate>cell codes go here</translate>''
<nowiki>|-</nowiki>
<span style="font-weight:bold; color:red">|</span> ''<translate>cells in the next row go here</translate>''
<span style="font-weight:bold; color:red">|</span> ''<translate>more cells in the same row here</translate>''
<nowiki>|}</nowiki>
* <translate>Cells can be separated with either a new line and new bar, or by a double bar <tvar name="1"><code>||</code></tvar> on the same line. Both produce the same output:</translate>
<nowiki>{|</nowiki>
<nowiki>|+</nowiki> <translate>The table's caption</translate>
<nowiki>|-</nowiki>
<span style="font-weight:bold; color:red">| <translate>Cell A1</translate> || <translate>Cell A2</translate> || <translate>Cell A3</translate></span>
<nowiki>|-</nowiki>
<span style="font-weight:bold; color:red">| <translate>Cell B1</translate></span>
<span style="font-weight:bold; color:red">| <translate>Cell B2</translate></span>
<span style="font-weight:bold; color:red">| <translate>Cell B3</translate></span>
<nowiki>|}</nowiki>
* <translate>If you use single bars, then what might appear to be the first cell is in fact a '''optional cell parameter''' applied to the cell to modify its format. The rest of your "cells" will be merged into one:</translate>
<nowiki>{|</nowiki>
<nowiki>|-</nowiki>
{{!}}<span style="font-weight:bold; color:red"><translate>optional cell parameter (not displayed)</translate>{{!}}</span><translate>These all</translate> <span style="font-weight:bold; color:red">{{!}}</span>(<translate>including the pipes</translate>)<span style="font-weight:bold; color:red">{{!}}</span><translate>go into</translate> <span style="font-weight:bold; color:red">{{!}}</span><translate>the first cell</translate>
<nowiki>|-</nowiki>
<nowiki>|}</nowiki>
:<translate>which is probably not what you want:</translate>
:{| class="wikitable"
|-
|<translate>optional cell parameter (not displayed)</translate>|<translate>These all</translate> |<translate>(including the pipes)</translate>|<translate>go into</translate> |<translate>the first cell</translate>
|-
|}
:<translate>However, the optional parameters are useful. Example:</translate>
<nowiki>{|</nowiki>
<nowiki>|-</nowiki>
{{!}}<translate>Cell 1 (no cell parameter - not aligned)</translate>
<nowiki>|-</nowiki>
{{!}}<span style="color:red">style="text-align:right;"{{!}}</span> <translate>Cell 2 (right aligned)</translate>
<nowiki>|-</nowiki>
<nowiki>|}</nowiki>

:{| class="wikitable" style="width:20em"
|-
|<translate>Cell 1 (no cell parameter - not aligned)</translate>
|-
|style="text-align:right;" |<translate>Cell 2 (right aligned)</translate>
|-
|}
:<translate>Just remember: no more than 2 single pipes on a line!</translate>

* <translate>A row of '''column headings''' is identified by using <tvar name="1"><code>!</code></tvar> instead of <tvar name="2"><code>|</code></tvar>, and using <tvar name="3"><code>!!</code></tvar> instead of <tvar name="4"><code>||</code></tvar>. Header cells typically render differently from regular cells, depending on the browser. They are often rendered in a bold font and centered.</translate>
<nowiki>{|</nowiki>
<nowiki>|+</nowiki> <translate>The table's caption</translate>
<span style="font-weight:bold; color:red">! <translate>Column heading 1</translate> !! <translate>Column heading 2</translate> !! <translate>Column heading 3</translate></span>
<nowiki>|-</nowiki>
| <translate>Cell A1</translate> || <translate>Cell A2</translate> || <translate>Cell A3</translate>
<nowiki>|-</nowiki>
| <translate>Cell B1</translate>
| <translate>Cell B2</translate>
| <translate>Cell B3</translate>
<nowiki>|}</nowiki>
* <translate>The first cell of a row is identified as '''row heading''' by starting the line with <tvar name="1"><code>!</code></tvar> instead of <tvar name="2"><code>|</code></tvar>, and starting subsequent data cells on a new line.</translate>
<nowiki>{|</nowiki>
<nowiki>|+</nowiki> <translate>The table's caption</translate>
! <translate>Column heading 1</translate> !! <translate>Column heading 2</translate> !! <translate>Column heading 3</translate>
<nowiki>|-</nowiki>
<span style="font-weight:bold; color:red">! <translate>Row heading A</translate></span>
| <translate>Cell A2</translate> || <translate>Cell A3</translate>
<nowiki>|-</nowiki>
<span style="font-weight:bold; color:red">! <translate>Row heading B</translate></span>
| <translate>Cell B2</translate>
| <translate>Cell B3</translate>
<nowiki>|}</nowiki>
* <translate>'''Optional parameters''' can modify the behavior of cells, rows or the entire table. For instance, a border could be added to the table with <tvar name="1"><code>border="1"</code></tvar>. Instead of defining new parameters for each table there are predefined [[#Style classes|style classes]]. The most common one is <tvar name="2"><code>class="wikitable"</code></tvar>:</translate>
<nowiki>{|</nowiki> <span style="color:red">class="wikitable"</span>
<nowiki>|+</nowiki> <translate>The table's caption</translate>
! <translate>Column heading 1</translate> !! <translate>Column heading 2</translate> !! <translate>Column heading 3</translate>
<nowiki>|-</nowiki>
! <translate>Row heading A</translate>
| <translate>Cell A2</translate> || <translate>Cell A3</translate>
<nowiki>|-</nowiki>
! <translate>Row heading B</translate>
| <translate>Cell B2</translate>
| <translate>Cell B3</translate>
<nowiki>|}</nowiki>
<translate>
The final table would display like this:
</translate>
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;">
{| class="wikitable"
|+ <translate nowrap>The table's caption</translate>
! <translate nowrap>Column heading 1</translate> !! <translate nowrap>Column heading 2</translate> !! <translate nowrap>Column heading 3</translate>
|-
! <translate nowrap>Row heading A</translate>
| <translate nowrap>Cell A2</translate> || <translate nowrap>Cell A3</translate>
|-
! <translate nowrap>Row heading B</translate>
| <translate nowrap>Cell B2</translate>
| <translate nowrap>Cell B3</translate>
|}
</blockquote>
<translate>
The table parameters and cell parameters are the same as in [[w:HTML|HTML]], see [https://www.w3.org/TR/html401/struct/tables.html#edef-TABLE The TABLE element] and [[w:HTML element#Tables|Table (HTML)]]. However, the <code>thead</code>, <code>tbody</code>, <code>tfoot</code>, <code>colgroup</code>, and <code>col</code> elements are currently not [[Special:MyLanguage/Help:HTML in wikitext#Permitted HTML|supported in MediaWiki]].

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 {{mlm|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 <code>&amp;nbsp;</code> as content to ensure that the cells are displayed. To show a visible pipe in a cell, use <code>&lt;nowiki>|&lt;/nowiki></code> or <code>&amp;#124;</code>.

With <code>colspan</code> and <code>rowspan</code> cells can span several columns or rows, see the [[#M.C3.A9lange|Mélange]] example below.

== Examples ==

=== Simple example ===

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.
</translate>

'''<translate>Wiki markup</translate>'''
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre><nowiki>
{|
| A
| B
|-
| C
| D
|}
</nowiki></pre></blockquote>

<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre><nowiki>
{|
| A || B
|-
| C || D
|}
</nowiki></pre></blockquote>

'''<translate>What it looks like in your browser</translate>'''
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;">
{|
| A
| B
|-
| C
| D
|}
</blockquote>
<translate>
=== Multiplication table ===
</translate>
'''<translate>Wiki markup</translate>'''
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre>
{| class="wikitable" style="text-align:center"
|+ <translate nowrap>Multiplication table</translate>
|-
! &amp;times; !! 1 !! 2 !! 3
|-
! 1
| 1 || 2 || 3
|-
! 2
| 2 || 4 || 6
|-
! 3
| 3 || 6 || 9
|-
! 4
| 4 || 8 || 12
|-
! 5
| 5 || 10 || 15
|}
</pre></blockquote>

<translate>'''What it looks like in your browser''' (see <tvar name="1">{{ll|Help:User style}}</tvar>)</translate>
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;">
{| class="wikitable" style="text-align:center"
|+ <translate nowrap>Multiplication table</translate>
|-
! &times; !! 1 !! 2 !! 3
|-
! 1
| 1 || 2 || 3
|-
! 2
| 2 || 4 || 6
|-
! 3
| 3 || 6 || 9
|-
! 4
| 4 || 8 || 12
|-
! 5
| 5 || 10 || 15
|}
</blockquote>
<translate>
=== Color; scope of parameters ===
</translate>
:''<translate>See also: <tvar name="1">{{ll|Wiki color formatting help}}</tvar></translate>''
<translate>
To specifying color of text and background for a single cell do as follows:
</translate>

'''<translate>Wiki markup</translate>'''
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;"><syntaxhighlight lang="html">
{|
| style="background:red; color:white" | abc
| def
| style="background:red;" | <span style="color:white"> ghi </span>
| jkl
|}
</syntaxhighlight></blockquote>

'''<translate>What it looks like in your browser</translate>'''
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;">
{|
| style="background:red; color:white" | abc
| def
| style="background:red;" | <span style="color:white"> ghi </span>
| jkl
|}
</blockquote>
<translate>
''Note:'' The old variant <tvar name="1"><code>bgcolor</code></tvar> is [<tvar name="url">https://www.w3.org/TR/html4/present/graphics.html#h-15.1.1</tvar> deprecated].

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:
</translate>

'''<translate>Wiki markup</translate>'''
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;"><syntaxhighlight lang="html">
{| style="background:yellow; color:green"
|-
| abc || def || ghi
|- style="background:red; color:white"
| jkl || mno || pqr
|-
| stu || style="background:#C1C1C1" | vwx || yz
|}
</syntaxhighlight></blockquote>

'''<translate>What it looks like in your browser</translate>'''
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;">
{| style="background:yellow; color:green"
|-
| abc || def || ghi
|- style="background:red; color:white"
| jkl || mno || pqr
|-
| stu || style="background:#C1C1C1" | vwx || yz
|}
</blockquote>
<translate>
To make the table blend in with the background, use <tvar name="1"><code>style="background:none"</code></tvar> or <tvar name="2"><code>style="background:transparent"</code></tvar> (Note that <tvar name="3"><code>style="background:inherit"</code></tvar> didn't work with old browsers like IE6).

See [[w:X11 color names|X11 color names]] and [[w:Web colors|web colors]]

=== Width, height ===

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.
</translate>

'''<translate>Wiki markup</translate>'''
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre><nowiki>
{| class="wikitable" style="width:75%; height:200px"
|-
| abc || def || ghi
|- style="height:100px"
| jkl || style="width:200px" |mno || pqr
|-
| stu || vwx || yz
|}
</nowiki></pre></blockquote>

'''<translate>What it looks like in your browser</translate>'''
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;">
{| class="wikitable" style="width:75%; height:200px"
|-
| abc || def || ghi
|- style="height:100px"
| jkl || style="width:200px" |mno || pqr
|-
| stu || vwx || yz
|}
</blockquote>
<translate>
Note that <code>style="</code>inline CSS<code>"</code> used to have no effect with some old browsers. Nowadays you don't have to worry about it but in the past if compatibility was important, equivalent older constructs like <tvar name="1"><code>style="width:75%;"</code></tvar> were used since they worked on more browsers.

==== Setting your column widths ====
If you wish to force column widths to your own requirements, rather than accepting the width of the widest text element in a column's cells, then follow this example. ''Note:'' The wrap-around of text is forced and the unit used in this example is [[w:Pixel|px (pixel)]].
</translate>
<blockquote style="background: white; border: 1px solid black; padding: 1em;"><pre>
{| class="wikitable"
! style="width:100px;" | <translate nowrap>Name</translate>
! style="width:200px;" | <translate nowrap>Effect</translate>
! style="width:200px;" | <translate nowrap>Games found in</translate>
|-
| <translate nowrap>Poké Ball</translate> || <translate nowrap>Regular Poké Ball</translate> || <translate nowrap>All versions</translate>
|-
| <translate nowrap>Great Ball</translate> || <translate nowrap>Better than a Poké Ball</translate> || <translate nowrap>All versions</translate>
|}
</pre></blockquote>

<blockquote style="background: white; border: 1px solid black; padding: 1em;">
{| class="wikitable"
! style="width:100px;" | <translate nowrap>Name</translate>
! style="width:200px;" | <translate nowrap>Effect</translate>
! style="width:200px;" | <translate nowrap>Games found in</translate>
|-
| <translate nowrap>Poké Ball</translate> || <translate nowrap>Regular Poké Ball</translate> || <translate nowrap>All versions</translate>
|-
| <translate nowrap>Great Ball</translate> || <translate nowrap>Better than a Poké Ball</translate> || <translate nowrap>All versions</translate>
|}
</blockquote>
<translate>
To set column widths in a table without headers, specify the width in the first cell for each column, like this. ''Note:'' The unit used in this example is [[w:Point (typography)|pt (point)]].:
</translate>
<blockquote style="background: white; border: 1px solid black; padding: 1em;"><pre>
{| class="wikitable"
|-
| style="width:100pt;" | <translate nowrap>This column is 100 points wide</translate>
| style="width:200pt;" | <translate nowrap>This column is 200 points wide</translate>
| style="width:300pt;" | <translate nowrap>This column is 300 points wide</translate>
|-
| blah || blah || blah
|}
</pre></blockquote>

<blockquote style="background: white; border: 1px solid black; padding: 1em;">
{| class="wikitable"
|-
| style="width:100pt;" | <translate nowrap>This column is 100 points wide</translate>
| style="width:200pt;" | <translate nowrap>This column is 200 points wide</translate>
| style="width:300pt;" | <translate nowrap>This column is 300 points wide</translate>
|-
| blah || blah || blah
|}
</blockquote>
<translate>
One application of setting the widths is aligning columns of consecutive tables:
</translate>
<blockquote style="background: white; border: 1px solid black; padding: 1em;">
{| style="width:100%;"
|''Automatic column widths:''
{| class="wikitable"
! <translate>Country</translate>
! <translate>Capital</translate>
|-
| <translate>The Netherlands</translate> || <translate>Amsterdam</translate>
|}

{| class="wikitable"
! <translate>Country</translate>
! <translate>Capital</translate>
|-
| <translate>France</translate> || <translate>Paris</translate>
|}
|''Fixed column widths:''
{| class="wikitable"
! style="width:150px;" | <translate>Country</translate>
! style="width:150px;" | <translate>Capital</translate>
|-
| <translate>The Netherlands</translate> || <translate>Amsterdam</translate>
|}

{| class="wikitable"
! style="width:150px;" | <translate>Country</translate>
! style="width:150px;" | <translate>Capital</translate>
|-
| <translate>France</translate> || <translate>Paris</translate>
|}
|}
</blockquote>
<translate>

=== Vertical alignment ===

By default data in tables is vertically centrally aligned, which results in odd-looking layouts like this:
</translate>
<blockquote style="background: white; border: 1px solid black; padding: 1em;">
{| class="wikitable"
|-
| style="width:10%;" | '''<translate nowrap>Row heading</translate>'''
| style="width:70%;" | <translate nowrap>A longer piece of text.</translate> 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 commodo consequat. Duis aute irure dolor in reprehenderit in voluptate 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.
| style="width:20%;" | <translate nowrap>A shorter piece of text.</translate>
|-
| '''<translate nowrap>Row heading</translate>'''
| <translate nowrap>A longer piece of text.</translate> 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 commodo consequat. Duis aute irure dolor in reprehenderit in voluptate 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.
| <translate nowrap>A shorter piece of text.</translate>
|}
</blockquote>
<translate>
To fix this, apply the <tvar name="1"><code>style="vertical-align:top;"</code></tvar> attribute to the rows. Unfortunately it is necessary to apply this individually to every single row. For the whole table you can use <tvar name="2"><code>class="toptextcells"</code></tvar> or <tvar name="3"><code>class="wikitable sortable toptextcells"</code></tvar>. For example:
</translate>
<blockquote style="background: white; border: 1px solid black; padding: 1em;"><pre>
{| class="wikitable"
|- style="vertical-align:top;"
| style="width:10%;" | '''<translate nowrap>Row heading</translate>'''
| style="width:70%;" | <translate nowrap>A longer piece of text.</translate> Lorem ipsum …
| style="width:20%;" | <translate nowrap>A shorter piece of text.</translate>
|- style="vertical-align:top;"
| '''<translate nowrap>Row heading</translate>'''
| <translate nowrap>A longer piece of text.</translate> Lorem ipsum …
| <translate nowrap>A shorter piece of text.</translate>
|}
</pre></blockquote>

<blockquote style="background: white; border: 1px solid black; padding: 1em;">
{| class="wikitable"
|- style="vertical-align:top;"
| style="width:10%;" | '''<translate nowrap>Row heading</translate>'''
| style="width:70%;" | <translate nowrap>A longer piece of text.</translate> 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 commodo consequat. Duis aute irure dolor in reprehenderit in voluptate 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.
| style="width:20%;" | <translate nowrap>A shorter piece of text.</translate>
|- style="vertical-align:top;"
| '''<translate nowrap>Row heading</translate>'''
| <translate nowrap>A longer piece of text.</translate> 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 commodo consequat. Duis aute irure dolor in reprehenderit in voluptate 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.
| <translate nowrap>A shorter piece of text.</translate>
|}
</blockquote>
<translate>

=== Positioning ===

One can position the table itself, and all contents in a row, and contents in a cell, but not with a single parameter for all contents in the table, see <tvar name="1">[[Template talk:Table demo]]</tvar>.

=== Mélange ===

Here's a more advanced example, showing some more options available for making up tables.

You can play with these settings in your own table to see what effect they have. Not all of these techniques may be appropriate in all cases; just because you can add colored backgrounds, for example, doesn't mean it's always a good idea. Try to keep the markup in your tables relatively simple. Remember, other people are going to be editing the article too! This example should give you an idea of what is possible, though.
</translate>

'''<translate>Wiki markup</translate>'''
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em; overflow:auto;"><syntaxhighlight lang="moin">
{| class="wikitable"
|+ '''<translate nowrap>An example table</translate>'''
|-
! <translate nowrap>First header</translate>
! colspan="2" style="background:#ffdead;" | <translate nowrap>Second header</translate>
|-
| style="border-bottom:3px dashed gray;" | <translate nowrap>dashed</translate>
| style="border-bottom:10px double black;" | <translate nowrap>double</translate>
| rowspan=2 style="border-bottom:hidden; vertical-align:top;" | <translate nowrap>hidden</translate>
|-
| style="border-bottom:3px dotted gray;" | <translate nowrap>dotted</translate>
| style="border-bottom:3px solid #A2A9B1;"<!--standard wikitable border color--> | <translate nowrap>solid</translate>
|-
| colspan="3" style="margin:1en auto;" |
{|
|+ '''<translate nowrap>A table in a table:</translate>'''
|-
| style="width:150px; text-align:center;" | [[File:Wiki.png]]
| style="width:150px; text-align:center;" | [[File:Wiki.png]]
|-
| colspan="2" style="border-top:1px solid #FF0000; border-right:1px solid red; border-bottom:2px solid red; border-left:1px solid red; text-align:center;" |
<translate nowrap>Two Wikimedia logos</translate>
|}
|}
</syntaxhighlight></blockquote>

'''<translate>What it looks like in your browser</translate>'''
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;">
{| class="wikitable"
|+ '''<translate nowrap>An example table</translate>'''
|-
! <translate nowrap>First header</translate>
! colspan="2" style="background:#ffdead;" | <translate nowrap>Second header</translate>
|-
| style="border-bottom:3px dashed gray;" | <translate nowrap>dashed</translate>
| style="border-bottom:10px double black;" | <translate nowrap>double</translate>
| rowspan=2 style="border-bottom:hidden; vertical-align:top;" | <translate nowrap>hidden</translate>
|-
| style="border-bottom:3px dotted gray;" | <translate nowrap>dotted</translate>
| style="border-bottom:3px solid #A2A9B1;"<!--standard wikitable border color--> | <translate nowrap>solid</translate>
|-
| colspan="3" style="margin:1en auto;" |
{|
|+ '''<translate nowrap>A table in a table:</translate>'''
|-
| style="width:150px; text-align:center;" | [[File:Wiki.png]]
| style="width:150px; text-align:center;" | [[File:Wiki.png]]
|-
| colspan="2" style="border-top:1px solid #FF0000; border-right:1px solid red; border-bottom:2px solid red; border-left:1px solid red; text-align:center;" |
<translate nowrap>Two Wikimedia logos</translate>
|}
|}
</blockquote>
<translate>

=== Floating table ===
</translate>
'''<translate>Wiki markup</translate>'''
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre>
<translate nowrap>This paragraph is before the table.</translate> 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...

{| class="wikitable" style="float:right;"
| <translate nowrap>Column 1, row 1</translate>
| rowspan="2" | <translate nowrap>Column 2, row 1 (and 2)</translate>
| <translate nowrap>Column 3, row 1</translate>
|-
| <translate nowrap>Column 1, row 2</translate>
| <translate nowrap>Column 3, row 2</translate>
|}
<translate nowrap>
Note the floating table to the right.
</translate>
<translate nowrap>This paragraph is after the table.</translate> 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...
</pre></blockquote>

'''<translate>What it looks like in your browser</translate>'''
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;">
<translate>This paragraph is before the table.</translate> 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...

{| class="wikitable" style="float:right;"
| <translate>Column 1, row 1</translate>
| rowspan="2" | <translate>Column 2, row 1 (and 2)</translate>
| <translate>Column 3, row 1</translate>
|-
| <translate>Column 1, row 2</translate>
| <translate>Column 3, row 2</translate>
|}
<translate>
Note the floating table to the right.
</translate>
<translate>This paragraph is after the table.</translate> 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...
</blockquote>{{-}}
<translate>
=== Non-floating tables ===
</translate>
'''<translate>Wiki markup</translate>'''
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre>
<translate nowrap>This paragraph is before the tables.</translate> 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...

{| class="wikitable"
|+ <translate nowrap>Left aligned table</translate>
| <translate nowrap>Column 1, row 1</translate>
|rowspan="2" | <translate nowrap>Column 2, row 1 (and 2)</translate>
| <translate nowrap>Column 3, row 1</translate>
|-
| <translate nowrap>Column 1, row 2</translate>
| <translate nowrap>Column 3, row 2</translate>
|}

<br style="clear:both;">

<translate nowrap>This paragraph is between the tables.</translate> 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...

{| class="wikitable" style="margin: 1em auto 1em auto;"
|+ <translate nowrap>Centered table</translate>
| <translate nowrap>Column 1, row 1</translate>
|rowspan="2"| <translate nowrap>Column 2, row 1 (and 2)</translate>
| <translate nowrap>Column 3, row 1</translate>
|-
| <translate nowrap>Column 1, row 2</translate>
| <translate nowrap>Column 3, row 2</translate>
|}

<br style="clear:both;">

<translate nowrap>This paragraph is after the tables.</translate> 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...
</pre></blockquote>

'''<translate>What it looks like in your browser</translate>'''
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;">
<translate>This paragraph is before the tables.</translate> 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...

{| class="wikitable"
|+ <translate>Left aligned table</translate>
| <translate>Column 1, row 1</translate>
|rowspan="2" | <translate>Column 2, row 1 (and 2)</translate>
| <translate>Column 3, row 1</translate>
|-
| <translate>Column 1, row 2</translate>
| <translate>Column 3, row 2</translate>
|}

<br style="clear:both;">

<translate>This paragraph is between the tables.</translate> 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...

{| class="wikitable" style="margin: 1em auto 1em auto;"
|+ <translate>Centered table</translate>
| <translate>Column 1, row 1</translate>
|rowspan="2"| <translate>Column 2, row 1 (and 2)</translate>
| <translate>Column 3, row 1</translate>
|-
| <translate>Column 1, row 2</translate>
| <translate>Column 3, row 2</translate>
|}

<br style="clear:both;">

<translate>This paragraph is after the tables.</translate> 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...
</blockquote>
<translate>
=== Nested tables ===

Five different (yellow) tables are shown nested inside the cells of a table. Automatically the two tables <tvar name="1">|A|</tvar> and <tvar name="2">|B|B|</tvar> are vertically aligned instead of the usual side by side of text characters in a cell. "<tvar name="3">float</tvar>" is used to fix each of tables <tvar name="4">|C|</tvar> and <tvar name="5">|D|</tvar> to their own position within one cell of the table. This may be used for charts and schemes. Nested tables must start on a new line.
</translate>

'''<translate>Wiki markup</translate>'''
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;">
<syntaxhighlight lang="xml" line highlight="4-8,11-16,18-23">
{| class="wikitable"
| &alpha;
| style="text-align:center;" | <translate nowrap>cell2</translate>
{| class="wikitable" style="background:#ffffcc" <!-- <translate nowrap>The nested table must be on a new line!</translate> -->
| <translate nowrap>NESTED</translate>
|-
| <translate nowrap>TABLE</translate>
|}
| style="vertical-algign:bottom;" | <translate nowrap>the original table again</translate>
| style="width:100px" |
{| class="wikitable" style="background:#ffffcc"
| A
|}
{| class="wikitable" style="background:#ffffcc"
| B || B
|}
| style="width:50px" |
{| class="wikitable" style="background:#ffffcc; float:left"
| C
|}
{| class="wikitable" style="background:#ffffcc; float:right"
| D
|}
|}
</syntaxhighlight></blockquote>
<translate>
'''What it looks like in your browser'''
</translate>
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;">
{| class="wikitable"
| &alpha;
| style="text-align:center;" | <translate>cell2</translate>
{| class="wikitable" style="background:#ffffcc"
| <translate>NESTED</translate>
|-
| <translate>TABLE</translate>
|}
| valign="bottom" | <translate>the original table again</translate>
| style="width:100px" |
{| class="wikitable" style="background:#ffffcc"
| A
|}
{| class="wikitable" style="background:#ffffcc"
| B || B
|}
| style="width:50px" |
{| class="wikitable" style="background:#ffffcc; float:left"
| C
|}
{| class="wikitable" style="background:#ffffcc; float:right"
| D
|}
|}
</blockquote>
<translate>

=== Combined use of <tvar name="1">COLSPAN</tvar> and <tvar name="2">ROWSPAN</tvar> ===
</translate>
'''<translate>Wiki markup</translate>'''
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre>
{| class="wikitable"
|-
! <translate nowrap>Column 1</translate> || <translate nowrap>Column 2</translate> || <translate nowrap>Column 3</translate>
|-
| rowspan="2"| A
| colspan="2" style="text-align:center;" | B
|-
| C &lt;!-- <translate nowrap>column 1 occupied by cell A</translate> --&gt;
| D
|-
| E
| rowspan="2" colspan="2" style="text-align:center;" | F
|-
| G &lt;!-- <translate nowrap>column 2+3 occupied by cell F</translate> --&gt;
|-
| colspan="3" style="text-align:center;"| H
|}
</pre></blockquote>

'''<translate>What it looks like in your browser</translate>'''
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;">
{| class="wikitable"
|-
! <translate nowrap>Column 1</translate> || <translate nowrap>Column 2</translate> || <translate nowrap>Column 3</translate>
|-
| rowspan="2"| A
| colspan="2" style="text-align:center;" | B
|-
| C <!-- <translate nowrap>column 1 occupied by cell A</translate> -->
| D
|-
| E
| rowspan="2" colspan="2" style="text-align:center;" | F
|-
| G <!-- <translate nowrap>column 2+3 occupied by cell F</translate> -->
|-
| colspan="3" style="text-align:center;" | H
|}
</blockquote>
<translate>
Note that using <tvar name="1"><code>rowspan="2"</code></tvar> for cell <tvar name="2">'''G'''</tvar> combined with <tvar name="3"><code>rowspan="3"</code></tvar> for cell <tvar name="4">'''F'''</tvar> to get another row below <tvar name="5">'''G'''</tvar> and <tvar name="6">'''F'''</tvar> won't work, because all (implicit) cells would be empty.

Likewise complete columns are not displayed if all their cells are empty. Borders between non-empty and empty cells might be also not displayed (depending on the browser), use <tvar name="1"><code>&amp;nbsp;</code></tvar> to fill an empty cell with dummy content.

=== Centering tables ===
Centered tables can be achieved, but they will not float; that is to say, no text will appear to either side. The trick is <tvar name="1"><code><nowiki>{| style="margin: 1em auto 1em auto"</nowiki></code></tvar>.
</translate>

'''<translate>Wiki markup</translate>'''
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre>
{| class="wikitable" style="margin: 1em auto 1em auto;"
|+ '''<translate nowrap>Cells left-aligned, table centered</translate>'''
! Duis || aute || irure
|-
| dolor || in reprehenderit || in voluptate velit
|-
| esse cillum dolore || eu fugiat nulla || pariatur.
|}
</pre></blockquote>

'''<translate>What it looks like in your browser</translate>'''
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;">
{| class="wikitable" style="margin: 1em auto 1em auto;"
|+ '''<translate nowrap>Cells left-aligned, table centered</translate>'''
! Duis || aute || irure
|-
| dolor || in reprehenderit || in voluptate velit
|-
| esse cillum dolore || eu fugiat nulla || pariatur.
|}
</blockquote>
<translate>
=== Setting parameters ===

At the start of a cell, add your parameter followed by a single pipe. For example <code>style="width:300px;"|</code> will set that cell to a width of 300 pixels. To set more than one parameter, leave a space between each one.
</translate>

'''<translate>Wiki markup</translate>'''
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre>
{| class="wikitable" style="color:white;"
|-
| style="background:red;" | <translate nowrap>cell1</translate> || style="background:blue; width:300px;"| <translate nowrap>cell2</translate> || style="background:green;"| <translate nowrap>cell3</translate>
|}
</pre></blockquote>

'''<translate>What it looks like in your browser</translate>'''
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;">
{| class="wikitable" style="color:white;"
|-
| style="background:red;" | <translate nowrap>cell1</translate> || style="background:blue; width:300px;"| <translate nowrap>cell2</translate> || style="background:green;"| <translate nowrap>cell3</translate>
|}
</blockquote>
<translate>

=== Decimal point alignment ===
==== With Template:0 ====
A simple and reliable way to achieve decimal point alignment is to use Template <code>[[w:Template:0|<nowiki>{{0}}</nowiki>]]</code>:
</translate>

''<translate>Wiki markup</translate>''
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre>
{{0|00,0}}12{{0|.00}} km<br />
{{0|00,0}}24.{{0|00}} km<br />
{{0|00,}}212.5{{0|0}} km<br />
{{0|0}}3,212.51&nbsp;km<br />
16,789.01&nbsp;km<br />
20,123.05&nbsp;km<br />
</pre></blockquote>
''<translate>What it looks like in your browser</translate>''
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;">
{{0|00,0}}12{{0|.00}} km<br />
{{0|00,0}}24.{{0|00}} km<br />
{{0|00,}}212.5{{0|0}} km<br />
{{0|0}}3,212.51&nbsp;km<br />
16,789.01&nbsp;km<br />
20,123.05&nbsp;km<br />
</blockquote>
<translate>

==== With a hidden table ====
Another method to get columns of numbers aligned at the decimal point is as follows:
</translate>

''<translate>Wiki markup</translate>''
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre>
{| cellpadding="0" cellspacing="0"
| style="text-align:right;" | 432 || .1
|-
| style="text-align:right;" | 43 || .21
|-
| style="text-align:right;" | 4 || .321
|}
</pre></blockquote>

''<translate>What it looks like in your browser</translate>''
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;">
{| cellpadding="0" cellspacing="0"
| style="text-align:right;" | 432 || .1
|-
| style="text-align:right;" | 43 || .21
|-
| style="text-align:right;" | 4 || .321
|}
</blockquote>
<translate>
==== With small hidden tables in each cell of a table ====
If the column of numbers appears in a table with cell padding or cell spacing, one can still align the decimal points without an unsightly gap in the middle. Embed a table in each number's cell and specify its column widths. Make the embedded tables' column widths the same for each cell in the column. (If decimal points are still misaligned using this method, the main table's column may be too narrow. Add a parameter to increase the column's width.)

</translate>
''<translate>Wiki markup</translate>''
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre>
{| class="wikitable" style="width:30%;"
|
{| cellpadding="0" cellspacing="0" style="width:100%;"
| style="width:50%; text-align:right;" | 432 || style="width:50%;" | .1
|}
|-
|
{| cellpadding="0" cellspacing="0" width="100%"
| style="width:50%; text-align:right;" | 43 || style="width:50%;"| .21
|}
|-
|
{| cellpadding="0" cellspacing="0" width="100%"
| style="width:50%; text-align:right;" | 4 || style="width:50%;" | .321
|}
|}
</pre></blockquote>

''<translate>What it looks like in your browser</translate>''
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;">
{| class="wikitable" style="width:30%;"
|
{| cellpadding="0" cellspacing="0" style="width:100%;"
| style="width:50%; text-align:right;" | 432 || style="width:50%;" | .1
|}
|-
|
{| cellpadding="0" cellspacing="0" width="100%"
| style="width:50%; text-align:right;" | 43 || style="width:50%;"| .21
|}
|-
|
{| cellpadding="0" cellspacing="0" width="100%"
| style="width:50%; text-align:right;" | 4 || style="width:50%;" | .321
|}
|}
</blockquote>
<translate>

==== With a monospaced font ====
In simple cases one can dispense with the table feature and simply start the lines with a space which changes the standard font to a [[:w:Monospaced font|Monospaced font]]. So you can put spaces to position the numbers:
</translate>
432.1
43.21
4.321
<translate>

== Style classes ==
</translate>
:''<translate>See also: <tvar name="1">{{ll|Help:User style}}</tvar></translate>''
<translate>
In the first line of table code, after the "<tvar name="1"><code>{|</code></tvar>", instead of specifying a style directly one can also specify a [[w:CSS|CSS]] class. The style for this class can be specified in various ways:
</translate>
* <translate>in the software itself, per skin (for example the class sortable, used at <tvar name="1">[https://en.wikipedia.org/skins-1.5/common/wikibits.js wikibits.js]</tvar>)</translate>
* <translate>collectively for all users of one wiki in <tvar name="1">[[MediaWiki:Common.css]]</tvar> (for example, on this and some other projects there is the class wikitable)</translate>
* <translate>separately per skin in <tvar name="1">[[MediaWiki:Monobook.css]]</tvar> etc.</translate>
* <translate>individually on one wiki in a user subpage</translate>
* <translate>individually, but jointly for tables of the class concerned on all web pages, on the local computer of the user.</translate>
<translate>
Instead of remembering table parameters, you just include an appropriate style class after the <tvar name="1"><code>{|</code></tvar>. This helps keep table formatting consistent, and can allow a single change to the class to fix a problem or enhance the look of all the tables that are using it at once. For instance, this:
</translate>
{| style="margin:1em auto;"
|-
! style="width:40em;" | <translate>Wiki markup</translate>
! style="width:30em;" | <translate>What it looks like in your browser</translate>
|-
|
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre>
{| border="1" cellpadding="2"
|+ <translate nowrap>Multiplication table</translate>
|-
! &amp;times; !! 1 !! 2 !! 3
|-
! 1
| 1 || 2 || 3
|-
! 2
| 2 || 4 || 6
|-
! 3
| 3 || 6 || 9
|-
! 4
| 4 || 8 || 12
|-
! 5
| 5 || 10 || 15
|}
</pre></blockquote>
|
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;">
{| border="1" cellpadding="2"
|+ <translate nowrap>Multiplication table</translate>
|-
! &times; !! 1 !! 2 !! 3
|-
! 1
| 1 || 2 || 3
|-
! 2
| 2 || 4 || 6
|-
! 3
| 3 || 6 || 9
|-
! 4
| 4 || 8 || 12
|-
! 5
| 5 || 10 || 15
|}
</blockquote>
|-
|colspan="2" style="text-align:center;" | <translate>becomes with wikitable this:</translate>
|-
|
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre>
{| class="wikitable"
|+ <translate nowrap>Multiplication table</translate>
|-
! &amp;times; !! 1 !! 2 !! 3
|-
! 1
| 1 || 2 || 3
|-
! 2
| 2 || 4 || 6
|-
! 3
| 3 || 6 || 9
|-
! 4
| 4 || 8 || 12
|-
! 5
| 5 || 10 || 15
|}
</pre></blockquote>
|
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;">
{| class="wikitable"
|+ <translate nowrap>Multiplication table</translate>
|-
! &times; !! 1 !! 2 !! 3
|-
! 1
| 1 || 2 || 3
|-
! 2
| 2 || 4 || 6
|-
! 3
| 3 || 6 || 9
|-
! 4
| 4 || 8 || 12
|-
! 5
| 5 || 10 || 15
|}
</blockquote>
|}
<translate>
Simply by replacing inline CSS for the table by <tvar name="1"><code>class="wikitable"</code></tvar>. This is because the <tvar name="2"><code>wikitable</code></tvar> class in <tvar name="3">[[MediaWiki:Common.css]]</tvar> and the "<tvar name="4"><code>../skins/common/shared.css</code></tvar>" file contain a number of <tvar name="5"><code>table.wikitable</code></tvar> [[w:CSS|CSS]] style rules. These are all applied at once when you mark a table with the class. You can then add additional style rules if desired. These override the class's rules, allowing you to use the class style as a base and build up on it:
</translate>
{| style="margin:1em auto;"
|-
! style="width:40em;" | <translate>Wiki markup</translate>
! style="width:30em;" | <translate>What it looks like in your browser</translate>
|-
|
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre>
{| class="wikitable" style="font-style:italic;
font-size:120%; border:3px dashed red;"
|+ <translate nowrap>Multiplication table</translate>
|-
! &amp;times; !! 1 !! 2 !! 3
|-
! 1
| 1 || 2 || 3
|-
! 2
| 2 || 4 || 6
|-
! 3
| 3 || 6 || 9
|-
! 4
| 4 || 8 || 12
|-
! 5
| 5 || 10 || 15
|}
</pre></blockquote>
|
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;">
{| class="wikitable" style="font-style:italic; font-size:120%; border:3px dashed red;"
|+ <translate nowrap>Multiplication table</translate>
|-
! &times; !! 1 !! 2 !! 3
|-
! 1
| 1 || 2 || 3
|-
! 2
| 2 || 4 || 6
|-
! 3
| 3 || 6 || 9
|-
! 4
| 4 || 8 || 12
|-
! 5
| 5 || 10 || 15
|}
</blockquote>
|}
<translate>
Notice that the table retains the gray background of the <tvar name="1"><code>wikitable</code></tvar> class, and the headers are still bold and centered. But now the text formatting has been overridden by the local <tvar name="2"><code>style</code></tvar> statement; all of the text in the table has been made italic and 120% normal size, and the wikitable border has been replaced by the red dashed border.

Of course this works only for browsers supporting inline CSS, if it's important use XHTML markup like <tvar name="1"><code>&lt;big&gt;</code></tvar> instead of "<tvar name="2">font-size:120%</tvar>", or Wiki markup like <tvar name="3"><code><nowiki>''text''</nowiki></code></tvar> instead of "<tvar name="4">font-style:italic</tvar>".

== Sorting ==

Tables can be made sortable by adding <tvar name="1"><code>class="wikitable sortable"</code></tvar>; for details see <tvar name="2">'''{{ll|Help:Sorting}}'''</tvar>. Since this can be very useful, it is wise to keep the possibilities and limitations of this feature in mind when designing a table. For example:
</translate>
* <translate>Do not divide a table into sections by subheaders spanning several rows. Instead, an extra column can be made showing the content of these headers on each row, in a short form.</translate>
* <translate>Do not have elements spanning several columns; instead, again, repeat the content on each row, in a short form.</translate>
* <translate>In a column of numbers, do not put text such as "<tvar name="1">ca.</tvar>" in front of a number—it will sort like zero. Do not put text after the number, and do not put a range of numbers (it does not affect the sorting position for numeric sorting mode, and in the case of a range, the first number determines the position, but if, possibly after sorting this or another column, the element is at the top, it will induce alphabetic sorting mode). Instead, put these texts in a separate column. Alternatively, for the greatest flexibility, alphabetic sorting mode with hidden sortkeys can be used.</translate>
<translate>
A long form of abbreviated content can be put as legend outside the table.
</translate>

'''<translate>Wiki markup</translate>'''
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre>
{| class="wikitable sortable"
|+ <translate nowrap>Sortable table</translate>
|-
! <translate nowrap>Alphabetic</translate> !! <translate nowrap>Numeric</translate> !! <translate nowrap>Date</translate> !! class="unsortable" | <translate nowrap>Unsortable</translate>
|-
| d || 2 || 2008-11-24 || <translate nowrap>This</translate>
|-
| b || 8 || 2004-03-01 || <translate nowrap>column</translate>
|-
| a || 6 || 1979-07-23 || <translate nowrap>cannot</translate>
|-
| c || 4 || 1492-12-08 || <translate nowrap>be</translate>
|-
| e || 0 || 1601-08-13 || <translate nowrap>sorted.</translate>
|}
</pre></blockquote>

'''<translate>What it looks like in your browser</translate>'''
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;">
{| class="wikitable sortable"
|+ <translate>Sortable table</translate>
|-
! <translate>Alphabetic</translate> !! <translate>Numeric</translate> !! <translate>Date</translate> !! class="unsortable" | <translate>Unsortable</translate>
|-
| d || 2 || 2008-11-24 || <translate>This</translate>
|-
| b || 8 || 2004-03-01 || <translate>column</translate>
|-
| a || 6 || 1979-07-23 || <translate>cannot</translate>
|-
| c || 4 || 1492-12-08 || <translate>be</translate>
|-
| e || 0 || 1601-08-13 || <translate>sorted.</translate>
|}
</blockquote>
<translate>
=== Sortable except final row ===
If the last row of the table should not be sorted (for example, if it contains the sum of figures in the preceding rows) use <tvar name="1"><code>class="sortbottom"</code></tvar> before the last row, as the following:
</translate>

'''<translate>Wiki markup</translate>'''
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre>
{| class="wikitable sortable"
|-
! <translate nowrap>Class</translate> !! <translate nowrap>Female</translate> !! <translate nowrap>Male</translate>
|-
| 1 || 22 || 65
|-
| 2 || 33 || 87
|-
| 3 || 15 || 45
|-
| 4 || 70 || 95
|-
| 5 || 65 || 110
|- class="sortbottom"
| Sum || 205 || 402
|}
</pre></blockquote>

'''<translate>What it looks like in your browser</translate>'''
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;">
{| class="wikitable sortable"
|-
! <translate>Class</translate> !! <translate>Female</translate> !! <translate>Male</translate>
|-
| 1 || 22 || 65
|-
| 2 || 33 || 87
|-
| 3 || 15 || 45
|-
| 4 || 70 || 95
|-
| 5 || 65 || 110
|- class="sortbottom"
| Sum || 205 || 402
|}
</blockquote>
<translate>
Note that formatting the last row as footer cells (i.e., using <tvar name="1"><code>!</code></tvar> and <tvar name="2"><code>!!</code></tvar> instead of <tvar name="3"><code>{{!}}</code></tvar> and <tvar name="4"><code>{{!}}{{!}}</code></tvar>) has the same effect. See [[<tvar name="1">Special:MyLanguage/Help:Sorting#Excluding the last row from sorting</tvar>|Help:Sorting § Excluding the last row from sorting]].

== Row template ==
Regardless of whether wikitable format or HTML is used, the wikitext of the rows within a table, and sometimes even within a collection of tables, has much in common, e.g.:
</translate>
* <translate>the basic code for a table row</translate>
* <translate>code for color, alignment, and sorting mode</translate>
* <translate>fixed texts such as units</translate>
* <translate>special formats for sorting</translate>
<translate>In that case it can be useful to create a template that produces the syntax for a table row, with the data as parameters. This can have many advantages:</translate>
* <translate>easily changing the order of columns, or removing a column</translate>
* <translate>easily adding a new column if many elements of the new column are left blank (if the column is inserted and the existing fields are unnamed, use a named parameter for the new field to avoid adding blank parameter values to many template calls)</translate>
* <translate>computing fields from other fields, e.g. population density from population and area</translate>
* <translate>duplicating content and providing span tags with "display:none" for the purpose of having one format for [[Help:Sorting|sorting]] and another for display</translate>
* <translate>easy specification of a format for a whole column, such as color and alignment</translate>
<translate>
Example:

Using <tvar name="1">{{ll|Help:Table/example row template}}</tvar>
</translate>
<pre>
{| class="wikitable sortable"
|-
! a
! b
! a/b
{{Help:Table/example row template| 50|200}}
{{Help:Table/example row template| 8| 11}}
{{Help:Table/example row template|1000| 81}}
|}
</pre>
<translate>
gives:
</translate>
{| class="wikitable sortable"
|-
! a
! b
! a/b
{{Help:Table/example row template| 50|200}}
{{Help:Table/example row template| 8| 11}}
{{Help:Table/example row template|1000| 81}}
|}
{{anchor|Conditional table row}}
<translate>
== Producing table syntax using templates and/or parser functions ==

When producing table syntax using templates and/or parser functions, a pipe character in a parameter has to be coded <tvar name="1"><code><nowiki>{{!}}</nowiki></code></tvar>, which uses <tvar name="2">[[Template:!]]</tvar>, to avoid being interpreted as parameter separator for the template or parser function. See <tvar name="3">[[Template:Table example with optional row]]</tvar>.

In the case of a conditional table row we typically need code of the form "<tvar name="1"><code><nowiki>{{!}}</nowiki>-</code>''newline''<code><nowiki>{{!}}</nowiki></code>.. ''newline''</tvar>" as then- or else-part of an if-construct. To avoid trimming, use a [[<tvar name="2">Special:MyLanguage/Category:Branching templates</tvar>|branching template]] (in this example <tvar name="3">[[Template:Ifnotempty]]</tvar>) that preserves the newline:
</translate>
{| class="wikitable"
! <translate>Code</translate> !! <translate>Result</translate>
|-
|<pre>
{| class=wikitable
{{ifnotempty|x|{{!}}-
{{!}}a
}}{{ifnotempty||{{!}}-
{{!}}b
}}{{ifnotempty||{{!}}-
{{!}}c
}}{{ifnotempty||{{!}}-
{{!}}d
}}{{ifnotempty|x|{{!}}-
{{!}}e
}}
|}
</pre>
|
{| class="wikitable"
{{ifnotempty|x|{{!}}-
{{!}}a
}}{{ifnotempty||{{!}}-
{{!}}b
}}{{ifnotempty||{{!}}-
{{!}}c
}}{{ifnotempty||{{!}}-
{{!}}d
}}{{ifnotempty|x|{{!}}-
{{!}}e
}}
|}
|}
<translate>
In order to avoid generate extra newlines, the end of one template is put in the same line as the start of another in the above example. You can also comment <tvar name="1"><code>&lt;!-- cmt --&gt;</code></tvar> around the newlines to avoid the same problem, or use empty <tvar name="2">{{tag|nowiki|s}}</tvar> tags. See <tvar name="3">{{ll|Help:Newlines and spaces}}</tvar> for more information.

Alternatively, XHTML table syntax can be used. It is not sensitive to line breaks and lets you avoid branching templates, <tvar name="1"><nowiki>{{=}}</nowiki></tvar> and extra <tvar name="2"><nowiki>{{!}}</nowiki></tvar> hacks.

== Other table syntax ==

Other types of '''table''' syntax that MediaWiki supports:
</translate>
# XHTML
# <translate>HTML <tvar name="1">{{tag|td|open}}</tvar> syntax ('''Do not use''')</translate>
<translate>All three are supported by MediaWiki and create (currently) valid HTML output, but the pipe syntax is the simplest. Also, HTML and wiki <tvar name="1">{{tag|td|open}}</tvar> syntax (i.e., unclosed <tvar name="1">{{tag|td|open}}</tvar> and <tvar name="2">{{tag|tr|open}}</tvar> tags), despite being proper HTML, may not be perfectly supported by other parsers and MediaWiki's cleanup procedures.</translate><!-- https://html.spec.whatwg.org/multipage/tables.html#table-descriptions-techniques -->
<translate>
Tables using HTML syntax can have pieces in templates only if the variable $wgUseTidy has been set, as is the case in most Wikimedia projects.

See also [[w:HTML element#Tables|HTML element#Tables]]. Note however that the <tvar name="1"><code>thead</code></tvar>, <tvar name="2"><code>tbody</code></tvar>, <tvar name="3"><code>tfoot</code></tvar>, <tvar name="4"><code>colgroup</code></tvar>, and <tvar name="5"><code>col</code></tvar> elements are currently not [[<tvar name="6">Special:MyLanguage/Help:HTML in wikitext#Permitted_HTML</tvar>|supported in MediaWiki]].
</translate>
{| class="wikitable collapsible autocollapse"
|+ <translate>Comparison of table syntax</translate>
! &nbsp;
! XHTML
! HTML
! <translate>Wiki-pipe</translate>
|-
! <translate>Table</translate>
| <syntaxhighlight lang="html" inline><table></table></syntaxhighlight>
| <syntaxhighlight lang="html" inline><table></table></syntaxhighlight>
| <!--wikEdOuterTableStart--><syntaxhighlight lang="html">{|
|}</syntaxhighlight>
|-
! <translate>Caption</translate>
| <syntaxhighlight lang="html" inline><caption>caption</caption></syntaxhighlight>
| <syntaxhighlight lang="html" inline><caption>caption</caption></syntaxhighlight>
| <syntaxhighlight lang="html">|+ <translate nowrap>caption</translate></syntaxhighlight>
|-
! <translate>Row</translate>
| <syntaxhighlight lang="html" inline><tr></tr></syntaxhighlight>
| <syntaxhighlight lang="html" inline><tr></syntaxhighlight>
| <syntaxhighlight lang="html">|-</syntaxhighlight>
|-
! <translate>Data cell</translate>
| <br /><syntaxhighlight lang="html" inline><td><translate nowrap>cell1</translate></td></syntaxhighlight><br /><br /><syntaxhighlight lang="html" inline><td><translate nowrap>cell2</translate></td></syntaxhighlight>
| <br /><syntaxhighlight lang="html" inline><td><translate nowrap>cell1</translate></syntaxhighlight><br /><br /><syntaxhighlight lang="html" inline><td><translate nowrap>cell2</translate></syntaxhighlight>
| <br /><syntaxhighlight lang="html">| <translate nowrap>cell1</translate>
| <translate nowrap>cell2</translate></syntaxhighlight>
|-
! <translate>Data cell</translate>
| <syntaxhighlight lang="html" inline><td><translate nowrap>cell1</translate></td> <td><translate nowrap>cell2</translate></td> <td><translate nowrap>cell3</translate></td></syntaxhighlight>
| <syntaxhighlight lang="html" inline><td><translate nowrap>cell1</translate><td> <translate nowrap>cell2</translate> <td><translate nowrap>cell3</translate></syntaxhighlight>
| <syntaxhighlight lang="html">| <translate nowrap>cell1</translate> || <translate nowrap>cell2</translate> || <translate nowrap>cell3</translate></syntaxhighlight>
|-
! <translate>Header cell</translate>
| <syntaxhighlight lang="html" inline><th><translate nowrap>heading</translate></th></syntaxhighlight>
| <syntaxhighlight lang="html" inline><th><translate nowrap>heading</translate></syntaxhighlight>
| <syntaxhighlight lang="html">! <translate nowrap>heading</translate></syntaxhighlight>
|-
! rowspan="2" | <translate>Sample table</translate>
| colspan="3" |
{| border="1" cellspacing="0" cellpadding="3" style="margin:1em auto;"
|-
| 1
| 2
|-
| 3
| 4
|}
|-
| <syntaxhighlight lang="html">
<table>
<tr>
<td>1</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>4</td>
</tr>
</table>
</syntaxhighlight>
| <syntaxhighlight lang="html">
<table>
<tr>
<td> 1 <td> 2
<tr>
<td> 3 <td> 4
</table>
</syntaxhighlight>
| <syntaxhighlight lang="html">
{|
| 1 || 2
|-
| 3 || 4
|}</syntaxhighlight>
|-
! rowspan="2" | <translate>Sample table</translate>
| colspan="3" |

{| border="1" cellspacing="0" cellpadding="3" style="margin:1em auto;"
|-
| 1
| 2
|-
| 3
| 4
|-
| 5
| 6
|}
|-
| <syntaxhighlight lang="html">
<table>
<tr>
<td>1</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>5</td>
<td>6</td>
</tr>
</table>
</syntaxhighlight>
| <syntaxhighlight lang="html">
<table>
<tr>
<td> 1 <td> 2
<tr>
<td> 3 <td> 4
<tr>
<td> 5 <td> 6
</table>
</syntaxhighlight>
| <syntaxhighlight lang="html">
{|
| 1 || 2
|-
| 3 || 4
|-
| 5 || 6
|}</syntaxhighlight>
|-
! <translate>Pros</translate>
|
* <translate>Can be previewed/debugged with any XHTML editor</translate>
* <translate>Can be formatted for easier reading</translate>
* <translate>Well-known</translate>
* <translate>Newlines not needed, but [[<tvar name="1">Special:MyLanguage/Help:Newlines and spaces#Conditional table rows</tvar>|to some extent allowed]]</translate>
* <translate>No characters like "<tvar name="1">|</tvar>" which can collide with template and parser function syntax</translate>
* <translate>Harder to shoot yourself in the foot with than HTML, since proper nesting and tag closure are enforced</translate>
|
* <translate>Can be previewed/debugged with any HTML editor</translate>
* <translate>Can be formatted for easier reading</translate>
* <translate>Well-known</translate>
* <translate>Takes less space than XHTML</translate>
* <translate>Newlines not needed, but [[<tvar name="1">Special:MyLanguage/Help:Newlines and spaces#Conditional table rows</tvar>|to some extent allowed]]</translate>
* <translate>No characters like "<tvar name="1">|</tvar>" which can collide with template and parser function syntax</translate>
|
* <translate>Easy to write</translate>
* <translate>Easy to read</translate>
* <translate>Takes little space</translate>
|-
! <translate>Cons</translate>
|
* <translate>Tedious</translate>
* <translate>Takes a lot of space</translate>
* <translate>Difficult to read quickly</translate>
|

|
* <translate>Unfamiliar syntax</translate>
* <translate>Rigid structure</translate>
* <translate>Cannot be indented (unless using a workaround via <tvar name="1">{{tag|blockquote|open}}</tvar>)</translate>
* <translate>Text (as in HTML tags) may be easier for some people to read than series of pipes, plus signs, exclamation marks, etc.</translate>
* <translate>Is nothing more than a shortcut for HTML-style tags. Not easily understood by those unfamiliar with HTML table concepts</translate>
* <translate>Assigning to a template parameter a value containing "<tvar name="1">|</tvar>" requires <tvar name="2">[[Template:!]]</tvar></translate>
* <translate>Sensitive to newlines; since these are automatically stripped from templates and parameters in some cases, special techniques are sometimes needed to avoid this, see <tvar name="1">{{ll|Help:Newlines and spaces}}</tvar></translate>
|-
! &nbsp;
! XHTML
! HTML
! <translate>Wiki-pipe</translate>
|}
<translate>
:''See also [[<tvar name="1">Template talk:For#Tables</tvar>|Template talk:For#Tables]]''

== Pipe syntax in terms of the HTML produced ==
The pipe syntax, developed by <tvar name="1">[[User:Magnus Manske|Magnus Manske]]</tvar>, substitutes pipes (<tvar name="2"><nowiki>|</nowiki></tvar>) for HTML. There is an [<tvar name="url">http://www.uni-bonn.de/~manfear/html2wiki-tables.php</tvar> on-line script] which converts html tables to pipe syntax tables.

The pipes must start at the beginning of a new line, except when separating parameters from content or when using <tvar name="1"><code>||</code></tvar> to separate cells on a single line. The parameters are optional.

=== Tables ===
A [[w:HTML element#Tables|table]] is defined by:
</translate>
<pre>
{| ''<translate nowrap>params</translate>''
|}
</pre>
<translate>
which equals
</translate>
<pre>
<table ''<translate nowrap>params</translate>''&gt;<translate nowrap>Insert non-formatted text here</translate>
</table>
</pre>
<translate>
=== Rows ===

<tvar name="1">{{tag|tr|open}}</tvar> tags will be generated automatically for the first row. To start a new row, use:
</translate>
|-
<translate>
which results in
</translate>
&lt;tr&gt;
<translate>
Parameters can be added like this:
</translate>
|- ''<translate>params</translate>''
<translate>
which results in
</translate>
&lt;tr ''<translate>params</translate>''&gt;
<translate>
Note:
</translate>
* <translate><tvar name="1">{{tag|tr|open}}</tvar> tags will be automatically opened at the first <tvar name="2">{{tag|td|open}}</tvar> equivalent</translate>
* <translate><tvar name="1">{{tag|tr|open}}</tvar> tags will be automatically closed at <tvar name="1">{{tag|tr|open}}</tvar> and <tvar name="1">{{tag|table|close}}</tvar> equivalents</translate>
<translate>
=== Cells ===

Cells are generated either like this:
</translate>
| <translate>cell1</translate>
| <translate>cell2</translate>
| <translate>cell3</translate>
<translate>
or like this:
</translate>
| <translate>cell1</translate> || <translate>cell2</translate> || <translate>cell3</translate>
<translate>
which both equal:
</translate>
&lt;td&gt;<translate>cell1</translate>&lt;/td&gt;&lt;td&gt;<translate>cell2</translate>&lt;/td&gt;&lt;td&gt;<translate>cell3</translate>&lt;/td&gt;
<translate>
so "<tvar name="1">||</tvar>" equals newline + "<tvar name="2">|</tvar>"

Parameters in cells can be used like this:
</translate>
| ''<translate>params</translate>'' | <translate>cell1</translate> || ''<translate>params</translate>'' | <translate>cell2</translate> || ''<translate>params</translate>'' | <translate>cell3</translate>
<translate>
which will result in:
</translate>
&lt;td ''<translate>params</translate>''&gt;<translate>cell1</translate>&lt;/td&gt;
&lt;td ''<translate>params</translate>''&gt;<translate>cell2</translate>&lt;/td&gt;
&lt;td ''<translate>params</translate>''&gt;<translate>cell3</translate>&lt;/td&gt;
<translate>
=== Headers ===

Functions the same way as <tvar name="1">{{tag|td|open}}</tvar>, except "<tvar name="2">!</tvar>" is used instead of the opening "<tvar name="3">|</tvar>". "<tvar name="4">!!</tvar>" can be used instead of "<tvar name="5">||</tvar>". Parameters still use "<tvar name="6">|</tvar>", though. For example:
</translate>
<nowiki>!</nowiki> ''<translate>params</translate>'' | <translate>cell1</translate>
<translate>
=== [[<tvar name="1">Special:MyLanguage/Help:Table caption</tvar>|Captions]] ===

A <tvar name="1">{{tag|caption|open}}</tvar> tag is created by:
</translate>
|+ <translate>Caption</translate>
<translate>
which generates
</translate>
&lt;caption&gt;<translate>Caption</translate>&lt;/caption&gt;
<translate>
You can also use parameters:
</translate>
|+ ''<translate>params</translate>''| <translate>Caption</translate>
<translate>
which will generate:
</translate>
&lt;caption ''<translate>params</translate>''&gt;<translate>Caption</translate>&lt;/caption&gt;
<translate>
== Square monitors ==

To format for a square monitor or window, use a tape measure. Determine the height of your rectangular screen. Using that figure measure under the screen to determine the width your monitor’s screen would be if it were square. Mark that location using ink or tape under the screen. Drag the side of your browser’s window to that location so the window is square based on accurate measurements. Square monitors and reading windows are not able to contain tables and galleries made for rectangular and wide screens. When a table or gallery is wider than the monitor, it makes every line of text wider than the screen as well. The px amounts of the following gallery were determined after measuring the window to make sure it was square:

Type this:
</translate>
<syntaxhighlight lang="moin" style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em; width:88%;">
{| border="0" style="background:transparent; margin:1em auto;"
|-
| [[File:Some window blinds.JPG|192x155px|thumb|left|<translate nowrap>Various window shades</translate>]]
| [[File:Vert-blinds-2145-rs.jpg|192x170px|thumb|left|<translate nowrap>Vertical blinds</translate>]]
| [[File:2008-08-24 Carpet array.jpg|192x155px|thumb|left|<translate nowrap>This is not a blind</translate>]]
|}

{| border="0" style="background:transparent; margin:1em auto;"
|-
| [[File:Vorhang.jpg|192x155px|thumb|left|<translate nowrap>Solid shade</translate>]]
| [[File:Jalousie-1.jpg|328x155px|thumb|left|<translate nowrap>Horizonal blinds</translate>]]
|}

{| border="0" style="background:transparent; margin:1em auto;"
|-
| [[File:Some window blinds.JPG|225px|thumb|left|<translate nowrap>Shade, shutters; vertical & horizontal blinds</translate>]]
| [[File:Miniblinds detail of mechanism.jpg|418px|thumb|left|<translate nowrap>Detail of turning rod (blind stick) attachment on miniblinds</translate>]]
|}
</syntaxhighlight>

<translate>
For this:
</translate>
{| border="0" style="background:transparent; margin:1em auto;"
|-
| [[File:Some window blinds.JPG|192x155px|thumb|left|<translate>Various window shades</translate>]]
| [[File:Vert-blinds-2145-rs.jpg|192x170px|thumb|left|<translate>Vertical blinds</translate>]]
| [[File:2008-08-24 Carpet array.jpg|192x155px|thumb|left|<translate>This is not a blind</translate>]]
|}

{| border="0" style="background:transparent; margin:1em auto;"
|-
| [[File:Vorhang.jpg|192x155px|thumb|left|<translate>Solid shade</translate>]]
| [[File:Jalousie-1.jpg|328x155px|thumb|left|<translate>Horizonal blinds</translate>]]
|}

{| border="0" style="background:transparent; margin:1em auto;"
|-
| [[File:Some window blinds.JPG|225px|thumb|left|<translate>Shade, shutters; vertical & horizontal blinds</translate>]]
| [[File:Miniblinds detail of mechanism.jpg|418px|thumb|left|<translate>Detail of turning rod (blind stick) attachment on miniblinds</translate>]]
|}
<translate>
== Viewing tables in email and web pages outside Wikipedia ==

Tables are an essential part of presenting information in an easily understandable way. Everything on Wikipedia can be copied elsewhere, and it is encouraged. But Wikipedia tables oftentimes lose their borders when pasted into web pages, blogs, or email.

The Wikipedia table button produces this:
</translate>
{| class="wikitable"
|-
! <translate>Header 1</translate>
! <translate>Header 2</translate>
! <translate>Header 3</translate>
|-
| <translate>Row 1, cell 1</translate>
| <translate>Row 1, cell 2</translate>
| <translate>Row 1, cell 3</translate>
|-
| <translate>Row 2, cell 1</translate>
| <translate>Row 2, cell 2</translate>
| <translate>Row 2, cell 3</translate>
|}
<translate>
Note the borders around all the cells, and the whole table. Copy and paste the table into your email, and the borders disappear. This makes the table look something like this below. It is much less understandable.
</translate>
{|
|
'''<translate>header 1</translate> <translate>header 2</translate> <translate>header 3</translate>'''
<translate>row 1, cell 1 row 1, cell 2 row 1, cell 3</translate>
<translate>row 2, cell 1 row 2, cell 2 row 2, cell 3</translate>
|}
<translate>
This is easily fixed. If you want and expect your table to be passed around in email, blogs, and other web pages, then add
</translate>
:'''border="1"'''
<translate>
somewhere in the first line of your chart wikicode. For example;
</translate>
{|
|
{| class="wikitable"</nowiki> '''border="1"'''
|-
! <translate>Header 1</translate>
! <translate>Header 2</translate>
! <translate>Header 3</translate>
|-
| <translate>Row 1, cell 1</translate>
| <translate>Row 1, cell 2</translate>
| <translate>Row 1, cell 3</translate>
|-
| <translate>Row 2, cell 1</translate>
| <translate>Row 2, cell 2</translate>
| <translate>Row 2, cell 3</translate>
|}
|}
<translate>
The table will look the same on the Wikipedia page, but it will now also have borders when copied into email, blogs, and other web pages. Bloggers and webmasters will not have to add [[w:CSS|CSS]] code in order to see the chart in a format with basic borders.
</translate>
<translate>
== Displaying the table code which generates a table ==

The code for a simple wiki markup table inside a ''Code box'' can be seen below.
</translate>
<!-- this is a misleading example, because style="text-align: center;" only works on the first cell, although it seems to work on the whole table -->
<pre>
{| border="5" cellspacing="10" cellpadding="2"
| style="text-align: center;" | [[File:gnome-system.png]]
|-
! <translate nowrap>Computer</translate>
|-
| <translate nowrap>Processor Speed: 1.8 GHz</translate>
|}
</pre>
<translate>
Above code produces/displays the table below:
</translate>
{| border="5" cellspacing="10" cellpadding="2" style="background-color: transparent;"
| style="text-align: center;" | [[File:gnome-system.png]]
|-
! <translate>Computer</translate>
|-
| <translate>Processor Speed: 1.8 GHz</translate>
|}
<translate>
Below code, generated and displayed the above table's ''Code box'' code itself, on the screen and web page, inside a blue colored dashed bordered rectangular box.
</translate>
{| border="0" cellpadding="2" cellspacing="0" style="background-color: transparent;"
| style="width:10%;" | &nbsp;
|<pre>
&#60;pre>
{| border="5" cellspacing="5" cellpadding="2"
| style="text-align: center;" | [[File:gnome-system.png]]
|-
! <translate nowrap>Computer</translate>
|-
| <translate nowrap>Processor Speed: 1.8 GHz</translate>
|}
&#60;/pre>
</pre>
| style="width:10%;" | &nbsp;
|}
<translate>
Note that, HTML tag <tvar name="1">'''{{tag|pre|open}}'''</tvar> was used to achieve displaying the above codes and the ''Code box''.

=== Other alternatives to display table code ===
</translate>
<translate>In most cases, when a code line is longer than the web browser window's width, then a scrolling bar appears at bottom, to let the viewer slide to the right side (and also left side) to see the rest of the codes, because, the use of <tvar name="1">{{tag|pre|open}}</tvar> tag causes the code line to remain intact, unless an [[w:End-of-line|EOL]] ([[w:Carriage return|CR]]/[[w:Line feed|LF]]) hidden character is reached in that text line.</translate> <translate>But having to slide or scroll to the right or left for viewing the full codes is often not comfortable to many readers.</translate> <translate>To solve such problem, using the <tvar name="1">{{tag|p|open}}</tvar>, <tvar name="2">{{tag|code|open}}</tvar> and <tvar name="3">{{tag|br|single}}</tvar> HTML tags, are better than using the <tvar name="4">{{tag|pre|open}}</tvar> tag, as those will limit the length of a line of code according the available space in the web browser's window and therefore will not result in the need to move the scroll-bar right (or left) for viewing.</translate> <translate>By placing the codes inside the <tvar name="1">{{tag|code}}</tvar> HTML tags, codes are displayed with a [[w:Non-proportional font|fixed width]] text/font, (like the <tvar name="2">{{tag|pre|open}}</tvar> tag uses) for easier reading. HTML tag <tvar name="3">{{tag|br|single}}</tvar> is used to display (or bring) next line of codes, starting from the next line.</translate> <translate>HTML tag <tvar name="1">{{tag|p|open}}</tvar> along with its CSS style properties, is used to create the blue colored dashed bordered rectangular box ('''''Code box''''') around the codes, (like the HTML <tvar name="2">{{tag|pre|open}}</tvar> tag, which gets these properties from the <tvar name="3">[https://en.wikipedia.org/style/monobook/main.css main.css]</tvar> stylesheet file).</translate>
<translate>
An example of table code with a long line is:
</translate>
<p style="width: 50em; padding: 1em; border: 1px dashed #2f6fab; color: Black; background-color: #f9f9f9; line-height: 1.1em;"> <code>
&#123;&#124; border="5" cellspacing="5" cellpadding="2" <br />
&#124; style="text-align: center;" &#124; &#91;&#91;File:gnome-system.png]] <br />
&#124;- <br />
&#33; <translate>Computer</translate> <br />
&#124;- <br />
&#124; style="color: yellow; background-color: green;" &#124; <translate>Processor Speed:</translate> &#60;span style="color: white;"> 1.8 GHz &#60;/span>''' <br />
&#124;&#125;
</code> </p>
<translate>
producing the below table:
</translate>
{| border="5" cellspacing="5" cellpadding="2"
| style="text-align: center;" | [[File:gnome-system.png]]
|-
! <translate>Computer</translate>
|-
| style="color: yellow; background-color: green;" | <translate>Processor Speed:</translate> <span style="color: white;">1.8 GHz</span>
|}
<translate>
''Code box'' above the table has the auto line wrapping feature enabled. Note the long line (the sixth line from top) inside the codes, which is wrapped inside the ''Code box''. This ''Code box'' and the codes, can be displayed by using below codes in the edit box.
</translate>
<p style="padding: 1em; border: 1px dashed #2f6fab; color: Black; background-color: #f9f9f9; line-height: 1.1em;"> <code>
&#60;p style="width: 50em; padding: 1em; border: 1px dashed #2f6fab; color: Black; background-color: #f9f9f9; line-height: 1.1em;"> &#60;code> <br />
&#60;nowiki><nowiki>{|</nowiki>&#60;/nowiki> border="5" cellspacing="5" cellpadding="2" &#60;br&nbsp;&#47;> <br />
| style="text-align: center;" | '''&#60;nowiki>'''<nowiki>[[</nowiki>'''&#60;/nowiki>'''File:gnome-system.png]] &#60;br&nbsp;&#47;> <br />
|- &#60;br&nbsp;&#47;> <br />
! <translate>Computer</translate> &#60;br&nbsp;&#47;> <br />
|- &#60;br&nbsp;&#47;> <br />
'''| style="color: yellow; background-color: green;" | <translate>Processor Speed:</translate> &#60;nowiki><nowiki><span style="color: white;"></nowiki>&#60;/nowiki> 1.8 GHz &#60;nowiki><nowiki></span></nowiki>&#60;/nowiki> &#60;br&nbsp;&#47;>''' <br />
&#60;nowiki><nowiki>|}</nowiki>&#60;/nowiki> &#60;br&nbsp;&#47;> <br />
&#60;/code> &#60;/p>
</code></p>

<translate>See the above codes, note that, <tvar name="1">{{tag|nowiki}}</tvar> tags were used to disable wiki markup codes for beginning a table (<tvar name="2"><code>{|</code></tvar>), ending a table (<tvar name="3"><code>|}</code></tvar>), start of an image displaying (<tvar name="4"><code>[[</code></tvar>), or a hyperlink, etc.</translate> <translate>All wiki &amp; HTML markup codes need to be disabled by enclosing them inside the <tvar name="1">{{tag|nowiki}}</tvar> tags.</translate> <translate>If these codes were to be displayed inside another table, then, each <tvar name="1"><code>|</code></tvar> ([[w:Vertical bar|vertical bar or "pipe"]]) and <tvar name="2"><code>!</code></tvar> (Exclamation mark) symbol also needed to be enclosed inside the <tvar name="3">{{tag|nowiki|open}}</tvar> tags.</translate> <translate>Note that, the longer line is automatically wrapped according to the width of the web browser's window, inside the ''Code box''.</translate>

<translate>Alternatively, we can replace each <tvar name="1"><code>|</code></tvar> (pipe symbol) character with <tvar name="2"><code>&amp;#124;</code></tvar> (HTML decimal entity code), replace each <tvar name="3"><code>!</code></tvar> ([[w:Exclamation mark|exclamation mark]]) with <tvar name="4"><code>&amp;#33;</code></tvar> code, replace <tvar name="5"><code>{</code></tvar> (beginning curly/second [[w:Bracket|bracket]]) with <tvar name="6"><code>&amp;#123;</code></tvar> and we may replace <tvar name="7"><code>}</code></tvar> (closing curly/second bracket) with <tvar name="8"><code>&amp;#125;</code></tvar> code.</translate> <translate>Also replace the <tvar name="1"><code><</code></tvar> (less than sign, or beginning angle bracket) with <tvar name="2"><code>&amp;#60;</code></tvar> numeric entity code or, replace it with <tvar name="3"><code>&amp;lt;</code></tvar> (HTML symbol entity code).</translate> <translate>For more on HTML decimal or [[w:Hexadecimal|hexadecimal]] numeric entity codes, please see [[w:Windows Alt codes|Windows Alt codes]].</translate> <translate>To display the wiki image markup code, we should replace the <tvar name="1"><code>[</code></tvar> (beginning square/third bracket) with <tvar name="2"><code>&amp;#91;</code></tvar> and we may replace <tvar name="3"><code>]</code></tvar> (closing square/third bracket) with <tvar name="4"><code>&amp;#93;</code></tvar>.</translate> <translate>When we are replacing characters with their numeric enitity codes, we are actually disabling their normal functionality, so we can display them on the web page(s).</translate>

{| border="0" style="width:100%;"
| <translate>By using the numeric entity codes, mentioned in the above paragraph, below codes can display the above ''Code box'' in another '''alternative (better)''' way. Note that, the ''longer line'' is automatically wrapped, without exceeding the browser window's width, inside the below ''Code box''.</translate>
| &nbsp;&nbsp;
| style="width:33%;" |
{| border="5" cellspacing="5" cellpadding="2" style="margin:1em auto;"
| style="text-align: center;" | [[File:gnome-system.png]]
|-
! <translate>Computer</translate>
|-
| style="color: yellow; background-color: green;" | <translate>Processor Speed:</translate> <span style="color: white;">1.8 GHz</span>
|}
|}

<p style="padding: 1em; border: 1px dashed #2f6fab; color: Black; background-color: #f9f9f9; line-height: 1.1em;"> <code>
&#60;p style="padding: 1em; border: 1px dashed #2f6fab; color: Black; background-color: #f9f9f9; line-height: 1.1em;"> &#60;code> <br />
&amp;#123;&amp;#124; border="5" cellspacing="5" cellpadding="2" &#60;br&nbsp;&#47;> <br />
&amp;#124; style="text-align: center;" &amp;#124; &amp;#91;&amp;#91;File:gnome-system.png]] &#60;br&nbsp;&#47;> <br />
&amp;#124;- &#60;br&nbsp;&#47;> <br />
&amp;#33; <translate>Computer</translate> &#60;br&nbsp;&#47;> <br />
&amp;#124;- &#60;br&nbsp;&#47;> <br />
'''&amp;#124; style="color: yellow; background-color: green;" &amp;#124; <translate>Processor Speed:</translate> &amp;#60;span style="color: red;"> 1.8 GHz &amp;#60;/span> &#60;br&nbsp;&#47;>''' <br />
&amp;#124;&amp;#125; &#60;br&nbsp;&#47;> <br />
&#60;/code> &#60;/p>
</code></p>
<translate>
See also [[<tvar name="1">Special:MyLanguage/Help:Advanced editing#Disabling wikitext interpretation and.2For reformatting</tvar>|disabling wikitext interpretation and/or reformatting]]. Another alternative is to display the source code within a <tvar name="2"><code>&lt;syntaxhighlight lang="html5"&gt;...&lt;/syntaxhighlight&gt;</code></tvar> element (with the additional benefit of keeping HTML comments visible, and coloring the HTML compatible syntax, even if the wiki-specific syntax itself is not colorized where it uses specific delimiters, like paired brackets <code><nowiki>[[…]]</nowiki></code> for wiki links, paired braces <code><nowiki>{{…}}</nowiki></code> for templates transclusion or parameters and tables, pipes between template parameters, pipes and exclamation marks between table cells in the same row, <code>__MAGIC__</code> keywords, and the specially recognized punctuation at start of lines for lists, indented blocks; preformated text and section headings; it also preserves source code indentation with whitespaces).

In that case you can easily format the source code for reasonnably short lines, simply by manually inserting newlines and reasonnable indentation, without modifying the source wiki code inserted directly in the source element. Embedding wiki code in a <tvar name="3">{{tag|syntaxhighlight}}</tvar> element is then interesting to use instead of embedding it in a <tvar name="4">{{tag|pre}}</tvar> element, whose rendering is more difficult to read for complex wiki code. That way the source code will render as follows:
</translate>
<syntaxhighlight lang="html5">
{| border="5" cellspacing="5" cellpadding="2"
| style="text-align: center;" | [[File:gnome-system.png]]
|-
! <translate nowrap>Computer</translate>
|-
| style="color: yellow; background-color: green;" | <translate nowrap>Processor Speed:</translate> <span
style="color: white;"> 1.8&nbsp;GHz </span><!-- <translate nowrap>this is a long wiki code line that has been manually wrapped and slightly indented.</translate> -->
|}
</syntaxhighlight>
<translate>
Note also that HTML named or numeric character entities (such as <tvar name="1"><code>&amp;nbsp;</code></tvar> or <tvar name="2"><code>&amp;#32;</code></tvar>) that are present in the embedded source code will not be substituted by the character they represent, but will be rendered verbatim (and colorized specifically).

But note that opening and closing <tvar name="3"><code>includeonly/noinclude/includeonly</code></tvar> tags that are present ''within'' the source code embedded in a <tvar name="4"><code>&lt;syntaxhighlight lang="html5"&gt;...&lt;/syntaxhighlight&gt;</code></tvar> element are still recognized by MediaWiki, and may cause parts of the code not being rendered; the only way to escape these tags is to alter them in the source by inserting some control (such as a zero-width space or word joiner) before or in the middle of their tag name.
</translate>
<translate>

== See also ==
</translate>
* <translate>[[w:Help:Introduction to tables with VisualEditor/1|Help:Introduction to tables with VisualEditor/1]] on Wikipedia</translate>
* <translate>[[mw:Special:MyLanguage/Help:Tables|Help:Tables]] on MediaWiki</translate>
* {{ll|Wiki table markup discussion history}}
* {{ll|Table background colors}}
* [[w:User:Dcljr/Tables]]
* <translate>[[w:HTML element#Tables|HTML element#Tables]] on Wikipedia</translate>
* [[Special:MyLanguage/Help:Template#A parameter value containing a pipe character|<translate>Help:Template#A parameter value containing a pipe character</translate>]]
* <translate>[[<tvar name="1">commons:Category:Commons charts and graphs</tvar>|Category:Commons charts and graphs]] on Wikimedia Commons</translate>
: <translate>Examples:</translate>
:* [[w:Template talk:Game of Go position|<translate>Go board</translate>]]
:* <translate>[[w::Monopoly (game)#Board|Monopoly board]] on Wikipedia</translate>
:* [[Template talk:Square 8x8 pentomino example|<translate>Square 8x8 pentomino example</translate>]]
* [[commons:Special:MyLanguage/Commons:Convert tables and charts to wiki code or image files|<translate>Commons:Convert tables and charts to wiki code or image files</translate>]]
<translate>
== External links ==
</translate>
* [http://area23.brightbyte.de/csv2wp.php csv2wp] - <translate>converts [[w:Comma-separated values|comma-separated values]] (CSV) format to pipe syntax. You may use this to import tables from Excel etc. ([[<tvar name="1">:de:Benutzer:Duesentrieb/csv2wp</tvar>|more information]])</translate>
*[http://sourceforge.net/projects/csv2other/ csv2other] - <translate>Takes in input an xls or a csv and outputs a file with wiki table format. Sources available. Still Alfa.</translate>
{{h:f|enname=Table}}


[[Category:Editor handbook{{#translation:}}]]
[[Category:Editor handbook{{#translation:}}]]

Latest revision as of 05:19, 20 February 2023