User:Smurrayinchester/Tutorial/Tables
- This is just a beginners guide. For the technical details, see Help:Tables.
In Wikipedia, a table is a way of arranging data into rows and columns, such as those seen in spreadsheets. They provide an easy and effective way to arrange numbers, lists, pictures, timelines and all the other stuff that won't work in normal prose.
When do I use a table?
UserBob has just finished his article on Crimblehampstead United FC, a famous (but alas entirely ficticious) football club. The article currently has sections about History, Players, Cup Titles and Stadium, all which are currently nothing but text. He wants to know where he should use a table to arrange this data.
History - Text only
- "Crimblehampstead United was formed in 1898 by the joining of Crimble Orient and Hampstead Athletic. This allowed a cash strapped CUFC to buy it's now famous Walingtonington Park stadium..."
The History section is mainly long paragraphs of prose, split into subsections. This would make a poor table, as there is only one set of data: the text.
Players - Text and tables
- "Crimblehampstead has some of the best players in Rutland, many of whom earn in excess of £20 a year. The team plays 4-4-2, with Barry Scott as the team's goalkeeeper, while Neville Longbottom and Jimmy Wales fill the forward roles..."
The Players section likewise consists mainly of text, but the bottom of the section has a list of positions and the players that fill them. This section should remain mostly text, but the bottom of the page could be arranged into a simple table.
Cup Titles - List tables
- "1921 - Rutland Cup, 1925 - Rutland U25s Cup, 1931 - Rutland Cup, 1941 - Crimblehampstead Borough Champions..."
The Cup Titles section is just a long list of years, and should definitely be made into a table; this is clearer and easier to sort.
Stadium - Infobox
- "The stadium was built on Walingtonington Park in 1901, and the inaugural match was played on the 25 December 1901, as a part of the Crimbleside Christmas celebrations. The stadium has a capacity of 20,000, which is often reached during the more competitive home games..."
This section is trickier, as there is numbers data mixed in with the prose. As a result, an Infobox can be used. This is perhaps beyond the scope of this tutorial, but a tutorial on infoboxes is pending.
The code
Wikipedia supports two methods of table layout: <DIV> and {|Curly braces|}. This tutorial will focus on the more intuitive curly braces, but both method are similar.
Firstly, UserBob must rearrange the Cup data.
To start a table, type{|. This tells Wikipedia that all the following data refers to a table. Next, leave a line, and then type |-. This indicator tells Wikipedia that you are now typing a new line. Leave another line, and press |. The pipes shows the start of a new row. Type the cell contents, and then type ||. This starts another cell on the same row.
Using these processes, Bob writes:
- {|
- |-
- | Year || Cup
- |-
- | 1921 || Rutland Cup
- |-
- | 1925 || Rutland Under-25s Cup
- |-
- | 1931 || Rutland Cup
- |-
- | 1941 || Crimblehampstead Borough Champions
- |}
Producing:
Year | Cup |
1921 | Rutland Cup |
1925 | Rutland Under-25s Cup |
1931 | Rutland Cup |
1941 | Crimblehampstead Borough Champions |
This is very basic, and hardly an improvement on the original! To make the text easier to read, the next step is to make the top row into a header row, by replacing | with !, like so:
- {|
- |-
- ! Year !! Cup
- |-
- | 1921 || Rutland Cup
- |-
- | 1925 || Rutland Under-25s Cup
- |-
- | 1931 || Rutland Cup
- |-
- | 1941 || Crimblehampstead Borough Champions
- |}
Year | Cup |
---|---|
1921 | Rutland Cup |
1925 | Rutland Under-25s Cup |
1931 | Rutland Cup |
1941 | Crimblehampstead Borough Champions |
It's getting better, but it's still a bit ugly. Luckily, Bob knows a shortcut. The colours of tables can be changed to make the layout simpler, and the easiest way is to use class="wikitable". Wikitable is the Wikipedia standard table, and it's as easy as pie to use. Simply put class="wikitable" straight after the {|, and the table automatically reformats!
- {| class="wikitable"
- |-
- ! Year !! Cup
- |-
- | 1921 || Rutland Cup
- |-
- | 1925 || Rutland Under-25s Cup
- |-
- | 1931 || Rutland Cup
- |-
- | 1941 || Crimblehampstead Borough Champions
- |}
Year | Cup |
---|---|
1921 | Rutland Cup |
1925 | Rutland Under-25s Cup |
1931 | Rutland Cup |
1941 | Crimblehampstead Borough Champions |
Now that looks professional!
More help and advice can be found at Help:Tables.