Wikia

WoWWiki

Help:Table

Talk4
102,254pages on
this wiki
Revision as of 07:32, June 8, 2010 by Keyesc (Talk | contribs)

HELP CONTENTS · Getting Started · New to WoWWIKI · Editing WoWWIKI · Editing WoWWIKI (advanced)
The WoWWIKI Community · Additional Help · Mists-Logo-Small Updating for Mists of Pandaria
See Wikia Help for general Wikia- and wiki- related help. See Metawiki logo 18x18 Meta-Wiki HelpIntro for basic MediaWiki usage!

MediaWiki supports different types of table syntax:

  1. Limited HTML syntax
  2. Pipe syntax (which this article covers)

See the Wikipedia article on HTML elements for notes on traditional HTML. Note, however, that the thead, tbody, tfoot, and colgroup elements are currently not supported in MediaWiki.[1]

The pipe syntax substitutes pipes (|) for HTML. The pipes must start at the beginning of a new line, except when separating optional parameters from content or when using || to separate cells on a single line.

Example table

{|
|-
! Header 1
! Header 2
! Header 3
|-
| row 1, cell 1
| R1/C2
| Cell 3
|-
| row 2, cell 1 || R2/C2 || Cell 3
|}

Would look like this:

Header 1 Header 2 Header 3
row 1, cell 1 R1/C2 Cell 3
row 2, cell 1 R2/C2 Cell 3

Tables

Use {| to open a table, and |} closes a table. Parameters (such as align, style, etc.) can be assigned added after the opening brackets.

Please use {| class="darktable" in WoWwiki tables to make them all purty-like:

Header 1 Header 2 Header 3
row 1, cell 1 R1/C2 Cell 3
row 2, cell 1 R2/C2 Cell 3

Note how each column automatically adjusts to the width of its widest cell.

Captions

Captions are the name of the table, centered just above it, and are created by adding a line with |+ (plus desired parameters) just after the table-opening line. |+ Put Caption Here produces:

Put Caption Here
Header 1 Header 2 Header 3
row 1, cell 1 R1/C2 Cell 3
row 2, cell 1 R2/C2 Cell 3

Rows

Rows are created with |-. Rows do not get closed; either start a new row or end the table.

Parameters added here will affect all cells in the row. |- align="right" for the 2nd row produces:

Header 1 Header 2 Header 3
row 1, cell 1 R1/C2 Cell 3
row 2, cell 1 R2/C2 Cell 3

Cells

Cells can be entered in two formats. On separate lines, as in row 1 of our example table; or all on one line, as in row 2.

Parameters only affect their cell, and can be used in both formats:

|param="<value>"|Cell1
|param="<value>"|Cell2

or

|param="<value>"|Cell1||param="<value>"|Cell2

Like rows, cells are not closed; simply start a new row or close the table.

Headers

Headers are simply the top-most cells in a column, or the left-most cells in a row. They describe the contents of that column or row. They use ! instead of the | used for regular cells, but parameters still use "|".

Like normal cells, headers can be listed on separate lines (as in our example table), or all on one line:

!Header 1!!Header 2!!Header 3

Cell Parameters

  • style: values can be "background-color:<color>", where <color> is a word, such as gray or red;
  • width: values can be "<x>px" where <x> is the number of pixels

Example:

!style="background-color:gray;" width="300px"|Header 1!!style="background-color:gray;" width="200px"|Header 2

Sorting

Columns on a table are made sortable by adding a class at the table opening: {| class="sortable"

Example Sortable Table
Alphabetical Numerical Reputation Surname
A 4 2 Revered Kir James T Kirk
C 3 3 Honored Rod Gene Roddenberry
B 2 4 FriendlyAnd John Anderson
D 1 1 Exalted Aze Bill Azeroth

Vic The Reputation column uses hidden, non-displaying numbers to determine sort order:

<span style="display:none">#</span>

Non-displaying letters can also be used to sort a list by surname if desired. For long lists, you should include at least the first few letters for sub-sorting names that start with the same letter.

<span style="display:none">Aze</span> Bill Azeroth

Striped tables

In long tables, or in tables with multi-line rows, it may be desirable to visually distinguish rows. This is accomplished by making every other row use a different background with class="zebra" at the start:

{| class="darktable zebra"

This also works for sortable tables. The zebra tag ensures that the rows have alternating colors, even when the order of the rows is changed by sorting.

Example Striped Table
Alphabetical Numerical Reputation Surname
A 4 2 Revered Kirk
(James T.)
C 3 3 Honored Roddenberry
(Gene)
B 2 4 Friendly Anderson
(John)
D 1 1 Exalted Azeroth
(Bill)

You can also manually control the striping by using class="alt" at the beginning of the desired rows:

|-class="alt"

Rows with this tag will have the alternative color. This method is only advisable for non-sortable tables.

References

External links

Around Wikia's network

Random Wiki