Open main menu

User:Rogerhc/Tables 2 col

Do not use a table unless you need to. Tables complicate editing. For some content however tables help readability enough to warrant this extra trouble. Tables done in wiki markup are a little easier to edit than HTML tables, which also work. This page shows how to do table in wiki markup, from simple to complicated.

Simple tableEdit

PlainEdit

The following table lacks borders and good spacing but shows the simplest wiki markup table structure

Orange Apple
Bread Pie
Butter Ice cream
{|
|Orange
|Apple
|-
|Bread
|Pie
|-
|Butter
|Ice cream 
|}

AlternativeEdit

For more table-ish looking wiki markup cells can be listed on one line separated by ||. This does not scale well for longer cell content such as paragraphs. It works well for short bits of content however, such as our example table.

Extra spaces within cells in the wiki markup can be added, as I have done in the wiki markup below, to make the wiki markup itself look better but they do not effect the actual table rendering.

HTML attributes can be added to this table following the examples in other tables on this page but have been left out of the following example for simplicity.

Orange Apple more
Bread Pie more
Butter Ice cream and more
{|
|  Orange    ||   Apple   ||   more
|-
|   Bread    ||   Pie     ||   more
|-
|   Butter   || Ice cream ||  and more
|}

With HTML attributesEdit

You can add HTML attributes to make your table look better

border="1"Edit

Orange Apple
Bread Pie
Butter Ice cream
{| border="1"
|Orange
|Apple
|-
|Bread
|Pie
|-
|Butter
|Ice cream 
|}

align="right" border="1"Edit

You can put attributes on individual cells. Numbers for example may look better aligned right

Orange Apple 12,333.00
Bread Pie 500.00
Butter Ice cream 1.00
{| border="1"
|Orange
|Apple
|align="right"|12,333.00
|-
|Bread
|Pie
|align="right"|500.00
|-
|Butter
|Ice cream
|align="right"|1.00
|}

cellspacing="0" border="1"Edit

Orange Apple
Bread Pie
Butter Ice cream
{| cellspacing="0" border="1"
|Orange
|Apple
|-
|Bread
|Pie
|-
|Butter
|Ice cream 
|}

cellpadding="30" cellspacing="0" border="1"Edit

Orange Apple
Bread Pie
Butter Ice cream
{| cellpadding="30" cellspacing="0" border="1"
|Orange
|Apple
|-
|Bread
|Pie
|-
|Butter
|Ice cream 
|}

With HTML attributes and CSS stylesEdit

CSS style attributes can be added with or without other HTML attributes

style="color:green;background-color:#ffffcc;" cellpadding="30" cellspacing="0" border="1"Edit

Orange Apple
Bread Pie
Butter Ice cream
{| style="color:green;background-color:#ffffcc;" cellpadding="30" cellspacing="0" border="1"
|Orange
|Apple
|-
|Bread
|Pie
|-
|Butter
|Ice cream 
|}

Table with headingsEdit

Headings can be added by usingĀ ! instead of |. Headings usually show up bold and centered by default.

Top headingsEdit

Yummy Yummier
Orange Apple
Bread Pie
Butter Ice cream
{| border="1" cellpadding="20" cellspacing="0"
!Yummy
!Yummier
|-
|Orange
|Apple
|-
|Bread
|Pie
|-
|Butter
|Ice cream 
|}

Side headingsEdit

DefaultEdit

Fruit Orange Apple
Dish Bread Pie
Complement Butter Ice cream
{| border="1" cellpadding="20" cellspacing="0"
!Fruit
|Orange
|Apple
|-
!Dish
|Bread
|Pie
|-
!Complement
|Butter
|Ice cream 
|}

Right justifiedEdit

Right justified side headings can be done as follows

Fruit Orange Apple
Dish Bread Pie
Complement Butter Ice cream
{| border="1" cellpadding="20" cellspacing="0"
!align="right" |Fruit
|Orange
|Apple
|-
!align="right" |Dish
|Bread
|Pie
|-
!align="right" |Complement
|Butter
|Ice cream 
|}