This page is a help page
It is meant to detail processes or procedures of some aspect or aspects of The Sims 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 The Sims 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 start, required
|
|+
|
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.
Inserting tables using the toolbar[edit source]
The easiest way to insert a table is to use the "Insert table" option found on the edit toolbar.
Vector toolbar – default
Monobook 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.
Tables, in their most basic form, do not contain any boxes or lines, making them a good way to place text side-by-side.
You type
|
You get
|
{|
|Orange
|Apple
|-
|Bread
|Pie
|-
|Butter
|Ice cream
|}
|
Orange
|
Apple
|
Bread
|
Pie
|
Butter
|
Ice cream
|
|
|
|
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.
You type
|
You get
|
{|
|Orange||Apple||more
|-
|Bread||Pie||more
|-
|Butter||Ice<br/>cream||and<br/>more
|}
|
Orange |
Apple |
more
|
Bread |
Pie |
more
|
Butter |
Ice cream |
and more
|
|
|
|
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.
|
- Lorem ipsum dolor sit amet
- consetetur sadipscing elitr
- sed diam nonumy eirmod tempor invidunt
|
|
|
|
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.
You type
|
You get
|
{| class="wikitable"
|Orange
|Apple
|-
|Bread
|Pie
|-
|Butter
|Ice cream
|}
|
Orange
|
Apple
|
Bread
|
Pie
|
Butter
|
Ice cream
|
|
|
|
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.
You type
|
You get
|
{| class="wikitable"
! style="text-align:left;"| Item
! Amount
! Cost
|-
|Orange
|10
|7.00
|-
|Bread
|4
|3.00
|-
|Butter
|1
|5.00
|-
!Total
|
|15.00
|}
|
Item
|
Amount
|
Cost
|
Orange
|
10
|
7.00
|
Bread
|
4
|
3.00
|
Butter
|
1
|
5.00
|
Total
|
|
15.00
|
|
|
|
Note that, when using attributes, the pipe character (|
) is always used for separation, never an exclamation mark (!
). More information on attributes is shown below.
A table caption can be added to the top of any table. They appear centered by default, and bolded if class="wikitable"
is used.
You type
|
You get
|
{| class="wikitable"
|+Food complements
|-
|Orange
|Apple
|-
|Bread
|Pie
|-
|Butter
|Ice cream
|}
|
Food complements
Orange
|
Apple
|
Bread
|
Pie
|
Butter
|
Ice cream
|
|
|
|
HTML colspan and rowspan[edit source]
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.
You type
|
You get
|
{| class="wikitable"
!colspan="6"|Shopping List
|-
|rowspan="2"|Bread & Butter
|Pie
|Buns
|Danish
|colspan="2"|Croissant
|-
|Cheese
|colspan="2"|Ice cream
|Butter
|Yogurt
|}
|
Shopping List
|
Bread & Butter
|
Pie
|
Buns
|
Danish
|
Croissant
|
Cheese
|
Ice cream
|
Butter
|
Yogurt
|
|
|
|
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).
You type
|
You get
|
{| class="wikitable sortable"
|-
! Fruit !! Price
|-
| Apples || £0.95
|-
| Oranges || £0.85
|-
| Pears || £1.15
|-
| Purple mangosteen || £1.05
|}
|
Fruit |
Price
|
Apples |
£0.95
|
Oranges |
£0.85
|
Pears |
£1.15
|
Purple mangosteen |
£1.05
|
|
|
|
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 start tag ({|
) will apply to the entire table.
You type
|
You get
|
{| class="wikitable" style="text-align: center; color: green;"
|Orange
|Apple
|12,333.00
|-
|Bread
|Pie
|500.00
|-
|Butter
|Ice cream
|1.00
|}
|
Orange
|
Apple
|
12,333.00
|
Bread
|
Pie
|
500.00
|
Butter
|
Ice cream
|
1.00
|
|
|
|
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 (!
).
You type
|
You get
|
{| class="wikitable"
| Orange
| Apple
| style="text-align:right;" | 12,333.00
|-
| Bread
| Pie
| style="text-align:right;" | 500.00
|-
| Butter
| Ice cream
| style="text-align:right;" | 1.00
|}
|
Orange
|
Apple
|
12,333.00
|
Bread
|
Pie
|
500.00
|
Butter
|
Ice cream
|
1.00
|
|
|
|
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.
You type
|
You get
|
{| class="wikitable"
| Orange || Apple || style="text-align:right;" | 12,333.00
|-
| Bread || Pie || style="text-align:right;" | 500.00
|-
| Butter || Ice cream || style="text-align:right;" | 1.00
|}
|
Orange |
Apple |
12,333.00
|
Bread |
Pie |
500.00
|
Butter |
Ice cream |
1.00
|
|
|
|
Attributes placed after the table row marker (|-
) will apply to the entire row.
You type
|
You get
|
{| class="wikitable"
| Orange
| Apple
| style="text-align:right;"| 12,333.00
|-
| Bread
| Pie
| style="text-align:right;"| 500.00
|- style="font-style: italic; color: green;"
| Butter
| Ice cream
| style="text-align:right;"| 1.00
|}
|
Orange
|
Apple
|
12,333.00
|
Bread
|
Pie
|
500.00
|
Butter
|
Ice cream
|
1.00
|
|
|
|
Attributes on captions[edit source]
Attributes placed after the table caption marker (+
) will apply to the caption.
You type
|
You get
|
{| class="wikitable"
|+ style="caption-side:bottom; color:#e76700;"|''Food complements''
|-
|Orange
|Apple
|-
|Bread
|Pie
|-
|Butter
|Ice cream
|}
|
Food complements
Orange
|
Apple
|
Bread
|
Pie
|
Butter
|
Ice cream
|
|
|
|
Simple one-pixel table border[edit source]
You type
|
You get
|
{| border="1" style="border-collapse:collapse"
| Orange
| Apple
|-
| Bread
| Pie
|}
|
|
|
|
If border-width
is called with only one number, it will apply to all four sides of the table.
You type
|
You get
|
{|style="border-style: solid; border-width: 20px"
|
Hello
|}
|
|
|
|
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
|}
|
|
|
|
A better way to define the border width for each side is to use border-left
, border-right
, border-top
, and border-bottom
.
You type
|
You get
|
{|style="border-left:solid 10px black;border-right:solid 20px black;border-top:solid 30px black;border-bottom:solid 40px black;" align="center"
|
Hello
|}
|
|
|
|
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.
With HTML attributes and CSS styles[edit source]
CSS style attributes can be used in tables as well. They can be combined with other HTML attributes, or just used on their own.
You type
|
You get
|
{| class="wikitable" style="color:green; background-color:#ffffcc;" cellpadding="10"
|Orange
|Apple
|-
|Bread
|Pie
|-
|Butter
|Ice cream
|}
|
Orange
|
Apple
|
Bread
|
Pie
|
Butter
|
Ice cream
|
|
|
|
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"
|}
|
Example of style="padding:10px"
|
Example of style="padding:50px"
Specify the padding on EACH CELL
|
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
|
Accessibility of table cells[edit source]
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:
You type
|
You get
|
{| class="wikitable"
|-
! scope="col"| Item
! scope="col"| Quantity
! scope="col"| Price
|-
! scope="row"| Bread
| 0.3 kg
| $0.65
|-
! scope="row"| Butter
| 0.125 kg
| $1.25
|-
! scope="row" colspan="2"| Total
| $1.90
|}
|
Item
|
Quantity
|
Price
|
Bread
|
0.3 kg
|
$0.65
|
Butter
|
0.125 kg
|
$1.25
|
Total
|
$1.90
|
|
|
|
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.
You type
|
You get
|
{| class="wikitable" style="margin-left: auto; margin-right: 0px;"
| Orange
| Apple
|-
| Bread
| Pie
|-
| Butter
| Ice cream
|}
|
Orange
|
Apple
|
Bread
|
Pie
|
Butter
|
Ice cream
|
|
|
|
To center-align a table, set both margins to auto.
You type
|
You get
|
{| class="wikitable" style="margin: auto;"
| Orange
| Apple
|-
| Bread
| Pie
|-
| Butter
| Ice cream
|}
|
Orange
|
Apple
|
Bread
|
Pie
|
Butter
|
Ice cream
|
|
|
|
Table floating around text[edit source]
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.
|
|
|
Cell contents alignment[edit source]
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
).
You type
|
You get
|
{| class="wikitable"
! Item
! Expense
|-
|Housing and Utilities
|900
|-
|Food
|700
|-
|Transportation
|-200
|-
|Medical
|0
|}
|
Item
|
Expense
|
Housing and Utilities
|
900
|
Food
|
700
|
Transportation
|
Medical
|
0
|
|
|
|
{| class="wikitable"
! Item
! Expense
|-
|Housing and Utilities
|900
|-
|Food
|700
|-
|Transportation
| -200
|-
|Medical
|0
|}
|
Item
|
Expense
|
Housing and Utilities
|
900
|
Food
|
700
|
Transportation
|
-200
|
Medical
|
0
|
|
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.