From StrategyWiki, the video game walkthrough and strategy guide wiki
Jump to navigation Jump to search
m (→‎Advanced tables: Expanded)
m (→‎Advanced tables: link updating)
Line 159: Line 159:


==Advanced tables==
==Advanced tables==
If you want more control over your tables, see the page on [[StrategyWiki:Guide/Tables/Advanced|advanced tables]]. 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 [[StrategyWiki:Administrators|sysop]].
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 [[StrategyWiki:Administrators|sysop]].


{{Footer Nav|game=StrategyWiki:Guide|prevpage=Images|nextpage=Templates|customnext=[[../Tables/Advanced|Advanced tables]]}}
{{Footer Nav|game=StrategyWiki:Guide|prevpage=Images|nextpage=Templates|customnext=[[../Advanced tables/]]}}

Revision as of 22:11, 26 August 2009

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

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 an "!", while normal cells start with a "|".
{|{{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 a "|+".
{|{{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 a "!".
{|{{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

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.

Sortable tables

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, and headings at the top of the table will acquire sort buttons. For example:

Explanatory table demonstrating sorting.
Alphabetic Numeric Random
A 65 Foo
C 12 Bar
B 53 Baz

Narrow/Floated tables

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 you're floating a table off to one side, you may want it to occupy as little width as possible. For this, you can use the "|notwide=1" parameter for {{prettytable}}, but if you're floating the table, you can instead use the "|float=left" or "|float=right" parameters, which will implicitly make the table narrow.

However, there may be other cases where you're not floating a table, but you do want it narrow. In such cases, put the "|notwide=1" parameter into the {{prettytable}} at the top of your table.

Text centering

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

If you know CSS, or want more information about the parameters for {{prettytable}}, they're described in detail in its documentation.

Advanced tables

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.