Help:Tables

Tables are commonly used on Starfield Wiki to organize information into columns. Although traditional HTML tags can be used to create a table (, ,  , etc.), the wiki software introduces a new set of table markup tags. This article focuses solely on the wiki table markup tags.

Introduction
A simple table looks like:

The code used to produce this table is:

The basic parts used to construct tables (as shown in this example) are:
 * : creates the start of the table. The first line, following the : part of the table definition, this class creates a table with a standard Starfield Wiki appearance.
 * and : provide the text for the column headers.
 * : defines the start of a new row.
 * and : provide the text for individual cells in the table.
 * : marks the end of the table.

Definition
All tables must start with: Although the wiki will try to fix the problem, the results are generally not what you wanted. If you find that parts of your table are showing up in strange places on the page, make sure that you have closed all of your tables. This  tag must be at the start of a new line to be recognized.

Rows
To start a new row of the table use: |- The  tag must be at the start of a new line. The contents of the row are not provided on the same row.

The only text that can be added following the  tag are parameters to change the formatting of the row. Two common usages follow.
 * This would make this one row all contain left-aligned text. "left" can be replaced by "right" or "center" for right-aligned or center-aligned text, respectively. This option applies only to the one row and will override any other options specified by the table's class or in the table's definition. However, individual cells may override the general row formatting.
 * This makes all cells in the row be vertically "top-aligned", i.e., the text in the cells starts at the very top of the cell.
 * This makes all cells in the row be vertically "top-aligned", i.e., the text in the cells starts at the very top of the cell.
 * This makes all cells in the row be vertically "top-aligned", i.e., the text in the cells starts at the very top of the cell.

Cells
Cells are generated either like this: |cell1 |cell2 |cell3 or like this: |cell1||cell2||cell3 The two types can be combined in various ways. For example: |cel11||cell2 |cell3

Any formatting options for the cell are supplied before the cell contents and separated from the contents using a  tag. Adding alignment options to the previous examples would be done as: |style="text-align:left"|cell1 |style="text-align:center"|cell2 |style="text-align:left"|cell3 or: |style="text-align:left"|cell1 |style="text-align:center"|cell2 |style="text-align:left"|cell3 or: |style="text-align:left"|cell1 |style="text-align:center"|cell2 |style="text-align:left"|cell3

Header Cells
Header cells are used to provide the column titles, and generally have bold text and a different background color for emphasis. They are specified similarly to standard Cells, except  or   is used instead the opening   or. When formatting is being provided for a header cell, one  and one   must be combined: !style="text-align:left"|cell1

Header cells can be specified anywhere in a table if desired. For example, the fourth column in every row could be made into a "header" format.

Captions
Captions are not generally used with Starfield Wiki tables. If you need to create one, however, use the tag: |+ Caption

Classes
Starfield Wiki has several predefined classes that provide the tables on the site with a uniform appearance and allow editors to quickly and easily create tables without learning detailed table formatting commands. These classes are defined in the site's CSS files and can only be modified by the site's Administrators.

The three classes used to specify overall table layout are:
 *  : The standard table layout used for nearly every table on SFW.
 *  : For tables that are used solely for organizing information where no table borders, margins, or backgrounds are desired. In many cases, this format of table is possible simply by omitting the class option from the table definition. However, there are situations such as nested tables where the hiddentable class is necessary.
 *  : For manually created tables of contents.

Additional classes exist that can be used to provide other formatting details. These classes are designed to be used in conjunction with one of the basic layout classes. For example,  (note that the optional classes follow the primary "wikitable" class). The available options are:
 *  : Centers the table horizontally on the page.
 *  : Eliminates all padding and margins to create smaller tables.
 *  : First column is left-aligned, the rest of the table is center-aligned.
 *  : Sets all cells in the table to have valign=middle (i.e., the content is all aligned vertically in the middle of the cell).
 *  : Sets all cells in the table to have valign=top (i.e., the content is all aligned vertically at the top of the cell). This is the default setting for tables, and therefore generally does not need to be used.

Sortable Tables
Another class that can be added for extra table features is. With this option, an icon is added to the header of each column; clicking on the icon causes the entire table to be sorted based upon the values in that column.

You can remove the sort icon from a column by giving the header the "unsortable" class. This example also adds the  option (see notes below):

You can also exclude a bottom row from sorting by giving it the "sortbottom" class: Keep in mind that only one row can be bottom-sorted in this way, and there is no way to top-sort a row.

Starfield Wiki's implementation of sortable tables is not the same as standard mediawiki sortable tables. Some additional features on SFW:
 * Adding the class  to the table in addition to   will cause every other row to automatically have a light gray background. This striping is updated every time the table is sorted (demonstrated in the second demo table above).
 * Row-spanning and column-spanning cells are supported in sortable tables.
 * Rowspan groups of rows are always kept together as a fixed unit when sorting.
 * The format of a column can be specified by setting the class of the first cell in the column. This is particularly useful if the column contains blank cells. Any cells that do not match the specified class are treated as blank. Possible classes are:
 * sort_num: sort column numerically
 * sort_date: sort column as a date
 * sort_str: sort column as a string
 * The column can be set to sort by default in descending order (with one click, instead of having to click twice for descending order). Do this by setting the class of the first cell in the column to:
 * sort_desc: descending sort order
 * Minor features:
 * Clicking on a column three times reverts the entire table to its original layout.
 * Line breaks are automatically inserted before the sortable column icon.
 * Several tweaks improve how dates and numbers are parsed.

Collapsible Tables
Sometimes a table becomes too large, or contains information that isn't always wanted on a page. In such cases, the table can be made collapsible. This places a link in the top right of the first column that allows the user to show or hide the contents of the table. Additionally, tables can be marked as collapsed, which causes the table to start in a hidden state.

Nested Table
{| width=100% {| class="wikitable"
 * - valign=top
 * width=50%|
 * width=50%|
 * blabla


 * the original table again
 * }
 * }