User:Hyacinth/How to use tables
From Wikipedia, the free encyclopedia
More information about creating and formatting tables in the manner described below may be found at http://meta.wikipedia.org/wiki/MediaWiki_User%27s_Guide:_Using_tables.
However, I felt the need to create this article because the above article is written for people who are used to creating tables using HTML markup as described at Wikipedia:How to use tables. So this article is for those who, like me, are unknowledgable.
Contents |
[edit] Making a table
To create a table, first type on a blank line "{|", which starts a table, and "|}" in next blank line, which ends the table:
{|
|}
[edit] Making the first row and column and their first cell
The first row is created by putting a "|" on the line in between your beginning and ending indicators.
{| border=1 align=center
|
|}
This line will be cell in the first cell in the first row and the first column. Enter any contents you wish to be in that cell by typing after the "|". Here I entered, "a simple table."
a simple table |
[edit] Formatting the table
After "{|" one may put any formatting that one wishes the table to have, such as a thin border, "{| border=1", or page alignment, "{| align=right".
{| border=1 align=center
|}
Other features include width (page width), "{| width=100%", and cell spacing, "{| cellspacing=0".
{| border=1 width=100%
| a || wide || table
|}
a | wide | table |
{| border=1 width=100% cellspacing=0
|a || wide || table || with || no || space || between || cells
|}
a | wide | table | with | no | space | between | cells |
[edit] Making the second and subsequent columns
To create the first cell of the first row in the second column simply enter "|" on the next line.
{| border=1 align=center
|
|
|}
a simple table | with one row and two columns |
One may also indicate another cell in a row by using two |s (||) or !! for column headings:
{| border=1 align=center
| ||
|}
[edit] Making the second and subsequent rows
To create a new row type "|-" after the last cell of the row before.
{| border=1 align=center
|
|-
|
|}
a simple table | with two columns |
and | two rows |
[edit] Making headings
To create a row of column headings type "!" in a row instead of "|" and "!!" as a cell divider rather than "||".
first column | second column |
---|---|
a simple table | with two columns |
two rows | and headings |
[edit] Formatting cells
To create a cell which spans one column but two rows, type "rowspan=2|" after "|".
{| border=1 align=center
|
|rowspan=2|
|-
|
|
|}
a not so simple table | with two rows | and three columns |
and typos | that's right |
To create a cell which spans one row but two columns, type "colspan=2|" after "|".
{| border=1 align=center
|colspan=2|
|-
|
|
|}
a not so simple table | |
with two rows | and two columns |
To align the text within cells one uses the same format as for whole tables:
{| border=1 align=center width=100%
|align=left|left
|align=right|and right
|}
left | and right |