Help:Tables

From YPPedia

Coding tables in Wiki markup is relatively simple but the finished result can often appear confusing at a glance. You can practice tables in the sandbox without disturbing real articles.

Basics

  • The entire code for the table must be between two sets of a curly bracket ({ or }) and pipe (|).
{|
  table code goes here
|}
  • To begin the code for a new row use a pipe and a dash on it's own line.
{|
|-
  cell code (cell on first row) goes here
|-
  cell code (cell on second row) goes here
|}
  • To put the code in each cell start a new line with a pipe and enter the cell's contents (can as simple as plain text or even empty). The next cell in the same row can either be started on a new line with a pipe or with a double pipe on the same line. These have the same effect and are user preferences.
{|
|-
|cell code goes here
|next cell code goes here
|-
|cell code goes here ||next cell code goes here
|}
  • A cell can be made a heading by replacing it's pipe (or pipes if using || to separate cells in a row).
{|
|-
!column heading code goes here!!next column heading code goes here
|-
!row heading code goes here 
|next cell code goes here
|}
  • You can add a caption to the table by adding a line beginning with a pipe and an addition sign. You can also define parameters, for example this border, after the first {|
{| border="1"
|+table caption 
|-
!Column 1!!Column 2!!Column 3
|-
!Row 1 
|Col 2 Row 1
|Col 3 Row 1
|-
!Row 2 
|Col 2 Row 2
|Col 3 Row 2
|}

This becomes:

table caption
Column 1 Column 2 Column 3
Row 1 Col 2 Row 1 Col 3 Row 1
Row 2 Col 2 Row 2 Col 3 Row 2


Further syntax

  • For the creation of more complex borders and altering the text and background of a table the 'style=' parameter can be used. To make it affect the entire table it should be placed after the first {| but on the same line. To affect a row add it after the |- of the relevant row. To affect only a single cell it should be placed before that cell's code, separated by it by a pipe. Some of the more common terms used within style= are:
    • 'color:' Changes the color of the text. (the value after the colon should be a standard color name, ie color:red or color:white)
    • 'background:' Changes the background color. (the value after the colon should be a standard color name, ie background:blue or background:silver)
    • 'text-align:' Specifies where in each cell the text should be placed. (the value after the colon should be either left, right or center)
    • 'font-style:' Sets special characteristics of the font ie bold, italics.
    • 'font-size:' Sets the size of the font. (value ater the colon should be a percentage, ie font-size:110%)
    • 'border:' Defines the border. (values after colon should be width of border in pixels, a space, line style, a space, then border color. ie border:2px dashed blue)

When using more than one of the above in a 'style=' parameter definition each should be separated by a semi-colon and a space. Also, all clauses after the should be wrapped in speech marks, ie style="color:white; background:blue".

For example:

{|style="color:white; background:black; border:2px dashed blue"
|+table caption 
|- style="color:white; background:blue"
!Column 1!!Column 2!!Column 3
|-
!Row 1 
|style="color:white; background:black; border:2px dashed blue"|Col 2 Row 1
|Col 3 Row 1
|-
!Row 2 
|Col 2 Row 2
|Col 3 Row 2
|}
table caption
Column 1 Column 2 Column 3
Row 1 Col 2 Row 1 Col 3 Row 1
Row 2 Col 2 Row 2 Col 3 Row 2


Stub.pngArr! This article be a stub. Ye can help YPPedia by expanding it.


External Links