Help:How To Use Tables

Revision as of 00:41, 9 April 2014 by 127.0.0.1 (talk) (moved How To Use Tables to Help:How To Use Tables: Moving to the Help namespace)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Related topics: Main Help, Wikipedia Tables

A Simple Example Edit

Basic Table Wiki Markup Edit

Wikitable Class Edit

The "wikitable" class provides a nice looking table without having to remember or specify all the details each time you create a table. This is because the wikitable class in MediaWiki:Common.css contains a number of table.wikitable CSS style rules. These are all applied at once when you mark a table with this class. You can then add additional style rules if desired. These override the class's rules, allowing you to use the class style as a base and build up on it.

Code:
{|class="wikitable"
!A
!B
|-
|100
|200
|}
Result:
A B
100 200

Colors Edit

Cell Borders Edit

Alignment Edit

Sorting Edit

Tables can be made sortable by adding class="sortable". For more details see Help:Sorting. If the table already has a class qualifier add sortable separated by a space, for example class="wikitable sortable".

Code:
{|class="wikitable sortable"
!A !!B !!C
|-
|500 ||200 ||Cat
|-
|300 ||400 ||Aardvark
|-
|100 ||50 ||Yak
|-
|}
Result:
A B C
500 200 Cat
300 400 Aardvark
100 50 Yak

Captions Edit

Nested Tables Edit

Colspan and Rowspan Edit

Frames Edit

This example demonstrates how to use the "frame" attribute to control the borders around a table. The thickness of the lines can be specified using "border" and the width in pixels. The frame feature is only supported in modern browsers. The first nine examples change only the frame parameter, the last three also change the border:

{|frame="??"
!A
!B
|-
|100
|200
|}
frame="border"

A B
100 200
frame="above"

A B
100 200
frame="below"

A B
100 200
frame="hsides"

A B
100 200
frame="vsides"

A B
100 200
frame="lhs"

A B
100 200
frame="rhs"

A B
100 200
frame="box"

A B
100 200
frame="void"

A B
100 200
frame="border" border="3"

A B
100 200
frame="hsides" border="2"

A B
100 200
frame="vsides" border="3"

A B
100 200

Decimal Point Alignment Edit