This page is a help page It is meant to detail processes or procedures of some aspect or aspects of K6ka's Wiki's norms and practices. It is not a policy page.
Tables are a way of organizing data using a series of columns and rows. Tables can be created on K6ka's Wiki using the wikitext syntax, and are highly customizable.
As a general rule, it is best to avoid using a table unless it's necessary or there is a lot of data to organize. Tables can complicate page editing.
table caption, optional; only between table start and table row
|-
table row, optional on first row—wiki engine assumes the first row
!
table header cell, optional. Consecutive table header cells may be added on same line separated by double marks (!!) or start on new lines, each with its own single mark (!).
|
table data cell, optional. Consecutive table data cells may be added on same line separated by double marks (||) or start on new lines, each with its own single mark (|).
|}
table end, required
All of the markup listed above must be placed on a new line, except for the double || and !! for adding consecutive cells to a line. Any blank spaces placed at the beginning of a line are ignored.
All of the markup, except for the table end, optionally accepts one or more HTML attributes, which must be placed on the same line as the mark. Attributes should be separated from each other with a single space.
Cells and caption (| or ||, ! or !!, and |+) hold content, so separate any attributes from its content with a single pipe (|). Cell content may follow on the same line or on the following lines.
Table and row marks ({| and |-) do not directly hold content. Do not add a pipe (|) after their optional attributes.
Content may either follow its cell mark on the same line (after any optional HTML attributes), or on lines below the cell mark. Any content that normally needs to go on a new line, such as lists and headings, must go on a new line.
To insert the pipe (|) character into a table, use the <nowiki>|</nowiki> escaping markup.
The easiest way to insert a table is to use the "Insert table" option found on the edit toolbar.
To automatically insert a table, click on the or buttons. The following text will be added:
{| class="wikitable"
|-
! Header text !! Header text !! Header text
|-
| Example || Example || Example
|-
| Example || Example || Example
|-
| Example || Example || Example
|}
Which renders as:
Header text
Header text
Header text
Example
Example
Example
Example
Example
Example
Example
Example
Example
You can customize this table as you see fit. For more advanced table settings, see below.
Cells in the same row can be listed on the same line if they are separated by two pipe symbols (||). If the text in the cell should contain a line break, use <br/> instead.
Single line breaks are taken into account on the line where the cell marker is; the following lines are rendered like normal wiki markup (single line breaks are ignored; other formatting, such as lists and even other tables, can be used).
You type
You get
{|
|Lorem ipsum dolor sit amet,
consetetur sadipscing elitr,
sed diam nonumy eirmod tempor invidunt
ut labore et dolore magna aliquyam erat,
sed diam voluptua.
At vero eos et accusam et justo duo dolores
et ea rebum. Stet clita kasd gubergren,
no sea takimata sanctus est Lorem ipsum
dolor sit amet.
|
* Lorem ipsum dolor sit amet
* consetetur sadipscing elitr
* sed diam nonumy eirmod tempor invidunt
|}
Lorem ipsum dolor sit amet,
consetetur sadipscing elitr,
sed diam nonumy eirmod tempor invidunt
ut labore et dolore magna aliquyam erat,
sed diam voluptua.
At vero eos et accusam et justo duo dolores
et ea rebum. Stet clita kasd gubergren,
no sea takimata sanctus est Lorem ipsum
dolor sit amet.
Tables can utilize a "class" parameter that loads predefined CSS into the table for styling. All wikis come with class="wikitable" available by default, which provides basic styling (by default, this is a light gray background, borders, padding and align left) for tables. More CSS classes can be added at MediaWiki:Common.css.
Table headers are created by using an exclamation mark (!) instead of a pipe (|). Headers show up bold and centered by default, and are usually placed at the top or leftmost-side of the table.
Note that, when using attributes, the pipe character (|) is always used for separation, never an exclamation mark (!). More information on attributes is shown below.
The HTML colspan and rowspan attributes allow you to create cells that span multiple columns (horizontally) and/or multiple rows (vertically). For example, specifying colspan="2" will cause the cell to span two columns instead of just one. When this is done, the table code must exclude the cells that are covered by such a span. The resulting row- and column-counting must fit.
It is possible to configure the columns of a table to be sortable, meaning that they will be sorted in alphabetical order when the headers are clicked (it is currently not possible to make a table be sorted automatically upon page load, aside from manually sorting the table in the wikitext of the page). To do this, add sortable to the class declaration, and ensure that the table is using headers (i.e. using an exclamation mark instead of a pipe character at the start).
Tables can accept HTML attributes to provide further customization and styling. For an authoritative source on HTML attributes for tables, see the W3C's website.
Attributes placed after the cell mark will apply to the respective cell. Note that the attribute must be separated from the content of the cell by a pipe character (!).
If you are listing multiple cells on the same line, the attributes are placed after the double marks (||). They must still be separated from the cell content by a single mark.
If border-width is called with more than one number, the four numbers are for top, right, bottom, left. Remember this order! If there is more than one number but less than four, the value for left takes its default from the value for right, the value for bottom takes its default from the value for top, and the value for right takes its default from the value for top.
You type
You get
{|style="border-style: solid; border-width: 10px 20px 100px 0"
|
Hello
|}
Hello
A better way to define the border width for each side is to use border-left, border-right, border-top, and border-bottom.
Note: The HTML attributes (such as "width=", "border=", "cellspacing=", "cellpadding=") do not need any length unit (the pixel unit is assumed). They are also invalid in HTML5.
"Cellpadding" is for setting the space between the cell wall and the cell content.[1]
The CSS style properties (which override the HTML attributes) require an explicit length unit (if the value is not 0) such as "px" for the pixel.
Padding can be applied to specify the amount of space between the cell walls and the contents of the cell.
You type
You get
{|class=wikitable
| style="padding: 10px" | Example of style="padding:10px"
|-
| style="padding: 50px" | Example of style="padding:50px"<br/><br/>Specify the padding on '''EACH CELL'''
|-
| style="padding:100px" | Example of style="padding:100px"
|}
The width style attribute can be added after the table start ({|) to specify the width of the entire table. Like other attributes, it can be placed after the cell mark (|) to specify the width of the column.
You type:
{| class="wikitable" style="width: 85%;"
| colspan="2" | This column width is 85% of the screen width
|-
| style="width: 30%"| '''This column is 30% counted from 85% of the screen width'''
| style="width: 70%"| '''This column is 70% counted from 85% of the screen width'''
|}
You get:
This column width is 85% of the screen width
This column is 30% counted from 85% of the screen width
This column is 70% counted from 85% of the screen width
Table header cells do not explicitly specify which table data cells they apply to (those on their right on the same row, or those below them on the same column). When the table is rendered in a visual 2D environment, this is usually easy to infer. However, when tables are rendered in a non-visual environment, such as for screen readers, it can be helpful to specify which table header cell applies to the description of any selected cell using the scope="col" and scope="row" attributes. In most cases with simple tables, you'll use scope="col" on all header cells of the first row, and scope="row" on the first cell of the following rows:
Table alignment is achieved by using CSS. Alignment is controlled by margins; a fixed margin on one side will align that table on that side, if the margin on the opposite site is defined as auto. For example, to align a table to the right, set the left margin to be auto, and the right margin to be 0px.
By default, tables break the text they are in, meaning that text does not appear on the sides of the table, which can make it look clearer. You can use the float attribute to allow the text to wrap around the table instead. When float is used, margins do not control the table alignment and are used instead to specify the margin between the table and the surrounding text.
You type
You get
{| class="wikitable" style="float:right; margin-left: 10px;"
| Orange
| Apple
|-
| Bread
| Pie
|-
| Butter
| Ice cream
|}
Lorem ipsum dolor sit amet, consectetuer adipiscing
elit, sed diam nonummy nibh euismod tincidunt ut
laoreet dolore magna aliquam erat volutpat. Ut wisi
enim ad minim veniam, quis nostrud exerci tation
ullamcorper suscipit lobortis nisl ut aliquip ex ea
commodo consequat. Duis autem vel eum iriure dolor
in hendrerit in vulputate velit esse molestie consequat,
vel illum dolore eu feugiat nulla facilisis at vero
eros et accumsan et iusto odio dignissim qui blandit
praesent luptatum zzril delenit augue duis dolore te
feugait nulla facilisi.
Orange
Apple
Bread
Pie
Butter
Ice cream
Lorem ipsum dolor sit amet, consectetuer adipiscing
elit, sed diam nonummy nibh euismod tincidunt ut
laoreet dolore magna aliquam erat volutpat. Ut wisi
enim ad minim veniam, quis nostrud exerci tation
ullamcorper suscipit lobortis nisl ut aliquip ex ea
commodo consequat. Duis autem vel eum iriure dolor
in hendrerit in vulputate velit esse molestie consequat,
vel illum dolore eu feugiat nulla facilisis at vero
eros et accumsan et iusto odio dignissim qui blandit
praesent luptatum zzril delenit augue duis dolore te
feugait nulla facilisi.
The alignment of the cell content themselves can be controlled using the text-align and vertical-align CSS properties. text-align can be applied to the entire table, row or individual cells, while vertical-align only can be applied to individual rows and cells.
You type
You get
{| class="wikitable"
|- style="vertical-align:top;"
| style="height:100px; width:100px; text-align:left;" | A
| style="height:100px; width:100px; text-align:center;" | B
| style="height:100px; width:100px; text-align:right;" | C
|- style="vertical-align:middle;"
| style="height:100px; width:100px; text-align:left;" | D
| style="height:100px; width:100px; text-align:center;" | E
| style="height:100px; width:100px; text-align:right;" | F
|- style="vertical-align:bottom;"
| style="height:100px; width:100px; text-align:left;" | G
| style="height:100px; width:100px; text-align:center;" | H
| style="height:100px; width:100px; text-align:right;" | I
|}
If you start a cell on a new line that starts with a minus sign (-), such as to list a negative number, the table may break as the minus sign will be interpreted together with the cell mark to mean a new row, not a table cell. To avoid this, insert a space before the value (| -6) or use in-line cell markup (|| -6).
Table borders specified through CSS rather than the border attribute will render incorrectly in a small subset of text browsers.
Common attributes for columns, column groups and row groups[edit source]
The MediaWiki syntax for tables currently offers no support for specifying common attributes for columns (with the HTML element <col />), column groups (HTML element <colgroup></colgroup>) and row groups (HTML elements <thead></thead>, <tbody></tbody> and <tfoot></tfoot>).
Those standard HTML elements are not accepted even in their HTML or XHTML syntax.
All the rows and cells (header or data) of the table are rendered within a single implicit row group (HTML element <tbody></tbody>) without any attributes or styles.