User:KenWalker/table

From Wikipedia, the free encyclopedia

Contents

[edit] Table

[edit] Basic table syntax

The following elements are delimited by line breaks, exceptions noted,

Element What it does
{| optional table parameters start table
|+ caption text caption, (optional but must be placed immediatly after {| if used)
|- optional row parameters new row
| cell text new cell
|| cell text new cell on same line in the code
| cell parameters | cell text new cell (with parameters)
|| cell parameters | cell text new cell (with parameters) on same line in the code
! heading text new heading
!! heading text new heading on same line in the code
! heading parameters | heading text new heading (with parameters)
!! heading parameters | heading text new heading (with parameters) on same line in the code
|} end table

Example:

This is the caption
Column 1 Column 2 Column 3
Row 1 1,1 1,2 1,3
Row 2 2,1 2,2 2,3
{|
|+ This is the caption
! !! Column 1 !! Column 2 !! Column 3
|-
! Row 1
| 1,1 || 1,2 || 1,3
|-
!Row 2
| 2,1
| 2,2
| 2,3
|}

[edit] Basic Parameters

[edit] Basic Table Parameters

Parameter What it does
border = value px specifies the border width in pixels
cellpadding = value px specifies cell padding in pixels
cellspacing = value px specifies cell spacing in pixels
width = value px/value% specifies table width in pixels or as a percent
align = left/right/center specifies table alignment

Example:

{|border = 3 px cellpadding = 3 px cellspacing = 3 px width = 60% align = center
! !! Column 1 !! Column 2 !! Column 3
|-
! Row 1
| 1,1 || 1,2 || 1,3
|-
!Row 2
| 2,1 || 2,2 || 2,3
|}

Result:

Column 1 Column 2 Column 3
Row 1 1,1 1,2 1,3
Row 2 2,1 2,2 2,3

[edit] Basic Row Parameters

bgcolor = color specifies cell background color for the row

[edit] Basic Cell Parameters

width = value px/value% specifies cell width in pixels or as a percent
align = left/right/center specifies cell text alignment
bgcolor = color specifies cell background color
rowspan = value specifies number of rows the cell will span
colspan = value specifies number of columns the cell will span

[edit] Style Parameters

[edit] Junk

[edit] class

class - an easy way to instantly improve the look of a table is to give it a class. Available classes include "wikitable" and wikitable small".

Example:

{| class = "wikitable"
|+ This is the caption
! !! Column 1 !! Column 2 !! Column 3
|-
! Row 1
| 1,1 || 1,2 || 1,3
|-
!Row 2
| 2,1
| 2,2
| 2,3
|}

Result:

This is the caption
Column 1 Column 2 Column 3
Row 1 1,1 1,2 1,3
Row 2 2,1 2,2 2,3


[edit] style

height

This is the caption
Column 1 Column 2 Column 3
Row 1 1,1 1,2 1,3
Row 2 2,1 2,2 2,3