From StrategyWiki, the video game walkthrough and strategy guide wiki
Jump to: navigation, search

Tables are a good way to present data more complex than a simple list. Although there is a lot of wikicode which can be used for creating and formatting tables on StrategyWiki, you generally only need to know a small subset to be able to deal with most situations.

Simple tables[edit]

A simple table will just have a header row, and then rows full of data below.

Description You type… You get…
Simple table with header row and three rows of data. Header cells start with "!" (exclamation mark), while normal cells start with "|" (pipe).
{|{{prettytable}}
! Header 1
! Header 2
! Header 3
|-
| Foo
| Bar
| Baz
|-
| Fiddle
| Middle
| Tiddle
|-
| Fi
| Fo
| Fum
|}
Header 1 Header 2 Header 3
Foo Bar Baz
Fiddle Middle Tiddle
Fi Fo Fum
The same table, but with the cell data compressed so that the wikicode occupies less space.
{|{{prettytable}}
! Header 1 !! Header 2 !! Header 3
|-
| Foo || Bar || Baz
|-
| Fiddle || Middle || Tiddle
|-
| Fi || Fo || Fum
|}
Header 1 Header 2 Header 3
Foo Bar Baz
Fiddle Middle Tiddle
Fi Fo Fum
Table with a caption, describing what the table shows. There can only be one caption per table, and its row starts with "|+".
{|{{prettytable}}
|+ Explanatory table demonstrating wikicode.
! Header 1 !! Header 2 !! Header 3
|-
| Foo || Bar || Baz
|-
| Fiddle || Middle || Tiddle
|-
| Fi || Fo || Fum
|}
Explanatory table demonstrating wikicode.
Header 1 Header 2 Header 3
Foo Bar Baz
Fiddle Middle Tiddle
Fi Fo Fum
You can also have header cells in each row, for example, if the first cell of each row is a heading for that row. Such header cells still begin with "!".
{|{{prettytable}}
! Header 1
! Header 2
! Header 3
|-
! Foo
| Bar
| Baz
|-
! Fiddle
| Middle
| Tiddle
|-
! Fi
| Fo
| Fum
|}
Header 1 Header 2 Header 3
Foo Bar Baz
Fiddle Middle Tiddle
Fi Fo Fum

{{prettytable}}[edit]

You may have noticed the {{prettytable}} template at the top of each of those tables. This template should be put at the top of every data table you create, as it styles the table correctly, and allows you to do some nice things. To add parameters to the prettytable template, separate them with "|" characters.

Ex.: {{prettytable|sortable=1|float=right|text center=1}}

Sortable tables[edit]

If your table contains a lot of numeric information, or things which the reader may want to look at in alphabetic order, you can put the "sortable=1" parameter into the {{prettytable}} at the top of your table. This makes headings at the top of the table acquire sort buttons. To suppress sorting for a single column, use the "unsortable" class in that column's header cell (see Advanced tables for details).

An explanatory table demonstrating the use of the "sortable" parameter.
Alphabetic Numeric Random
A 65 Foo
C 12 Bar
B 53 Baz

Narrow/Floated tables[edit]

By default, {{prettytable}} will make your table occupy the full width of the page (or its container). In most cases, this is what you want, but if it creates undue whitespace in the table, or you are putting multiple tables side-by-side in columns, you may want it to occupy as little width as possible. For this, you can use the "notwide=1" parameter for {{prettytable}}. If you're floating the table to the left or right, which allows text and other content to flow around it, you can instead use the "float=left" or "float=right" parameters, which will implicitly make the table narrow.

Text centering[edit]

Usually, text should be left-aligned in a table, but if (for example), the table contains lots of images, which would look better center-aligned, put the "text center=1" parameter into the {{prettytable}} at the top of your table, and all the contents will be center-aligned.

More flexibility[edit]

If you know CSS, or want more information about the parameters for {{prettytable}}, they're described in detail in its documentation. You can add table styles through the template by using the "style=styles" parameter. Note that quotes are not put around the styles.

Advanced tables[edit]

If you want more control over your tables, see the Advanced tables page. Note that it's discouraged for tables in general to use custom styling, as it breaks from the consistency of the site. If you want to change the styling of tables in your guide, talk to a sysop.