Help:Tables
From QED
| Help |
|
| Related topics |
For general help about tables, see Help:Table. For some examples, visit this gallery.
For help about color names that can be used with tables, see Color Names.
Contents |
Predefined Table Classes
There are some table classes which are universally available. They are defined on the MediaWiki:Common.css page and currently include wikitable and sortable.
For example, the effect of adding class=wikitable is illustrated by the following:
|
The above table on the right was produced by the following wikitable markup:
Sortable TablesSortable tables can be created on a page by using wikitable and/or HTML syntax. For example, you should be able to sort the rows of the following table in various ways by clicking on the column headings.
Notice the vertical arrows that appear. Here is the same table using class="sortable wikitable":
Notes
For further details, see Help:Sorting but note that currently, type declarations are not yet supported. Sortable Tables with wikitable SyntaxSimply mark your table as sortable, e.g. by declaring class=sortable or class="sortable wikitable", as shown using the following wikimarkup, which is rendered as shown above:
{| class=sortable
|-
! M || N || A
|-
| 12 || 78 || a
|-
| 14 || 76 || xyz
|-
| 16 || 74 || ab
|}
class=unsortable and class=sortbottomThe following wikimarkup produces the table below:
{| class="wikitable sortable" style="text-align:right"
!Numberic!!Alphabetic!!Dates!!Currency!!class="unsortable"|Unsortable
|-
|1||Z||02-02-2004||5.00||This
|-
|2||y||13-apr-2005||||Column
|-
|3||X||17.aug.2006||6.50||Is
|-
|4||w||01.Jan.2005||4.20||Actually
|-
|5||V||05/12/2006||7.15||Unsortable
|- class="sortbottom"
! Totals:{{repeat| |6}} 15!! !! !! {{repeat| |10}} 29.55 !!
|-
|}
The non-breaking spaces ( ) are for alignment. Sortable Tables with HTML SyntaxTo specify that a table is to be interactively sortable, add "sortable" to the table's list of classes as illustrated above. For example: <table class="sortable"> ExamplesTo see the HTML, press the page's edit or view tab, or the section's edit link if it appears.
AlignmentThe alignment of the content of cells within a table is governed by cell-specific specifications, row-specific specifications, and table-specific specifications. The most specific specification overrides all others. There is no direct way to specify alignment for a specific column. For horizontal alignment, style="text-align:X;" may be used, where X is one of left, right, center, or justified. ExampleIn this example, the specification for the table as a whole is "text-align:right" but the headings each have their own specifications:
{| style="text-align:right"
!width=100 align=left|LEFT
!width=100 align=center|CENTER
!width=100 align=right|RIGHT
|-
| a || b || c
|}
produces:
Alignment of Columns of Consecutive TablesOne approach is to specify the width of the corresponding columns as a percentage, as illustrated here: 8th century
9th century
The wikitext for the first of these two tables is as follows:
{| class="wikitable" width="100%"
! style="width:6%" | Year || style="width:10%" | Date || Event
|-
| 795 || || First Viking raids
|}
QuizzesThe <memorize> tag allows tables to be turned into interactive quizzes, as illustrated by the following example.
To turn the table into a quiz, click on one of the memorize links. See Help:Memorize for further details. Conversion to and from WikiTable SyntaxAn online copy-and-paste tool for converting from spreadsheets such as Microsoft Excel is available here. A fast, online, and accurate service for converting to or from HTML table syntax is available here. Other services are described here. Table-Related TemplatesThe following table illustrates Template:yes, Template:no, Template:dunno, and Template:partial:
For example, the "yes" row above is generated by the following line:
| yes || {{yes|}} || {{yes}} || {{yes|Oui}}
For other Table cell templates, see Template:Table cell templates. For other table-related templates, see Category:Table Template. See also |












