Help:Tables: Difference between revisions
mNo edit summary |
m Reverted edit of JurU1h, changed back to last version by Ivo |
||
| Line 14: | Line 14: | ||
<nowiki> |} </nowiki> | <nowiki> |} </nowiki> | ||
which equals | which equals | ||
<table ''params'' | <table ''params''> | ||
</table> | |||
:''Careful'': You '''must include''' the '''space''' between <code>'''{|'''</code> and <code>''params''</code>, or the first parameter gets ignored. | |||
=== TD === | |||
Cells are generated either like this: | |||
|cell1 | |||
|cell2 | |||
|cell3 | |||
or like this: | |||
|cell1||cell2||cell3 | |||
which both equals | |||
<td>cell1</td><td>cell2</td><td>cell3</td> | |||
so "||" equals "newline"+"|" | |||
Parameters in cells can be used like this: | |||
|''params''|cell1 | |||
which will result in | |||
<td ''params''> | |||
=== TH === | |||
Functions the same way as TD, except "!" is used instead the opening "|". "!!" can be used instead of "||". Parameters still use "|", though! | |||
=== TR === | |||
<tr> tags will be generated automatically for the first row. To start a new row, use | |||
|- | |||
which results in | |||
<tr> | |||
Parameters can be added like this: | |||
|- ''params'' | |||
which results in | |||
<tr ''params''> | |||
Note: | |||
* <tr> tags will be automatically opened at the first <td> equivalent | |||
* <tr> tags will be automatically closed at <tr> and </table> equivalents | |||
=== CAPTION === | |||
A <caption> tag is created by | |||
|+ Caption | |||
which generates | |||
<caption>Caption</caption> | |||
You can also use parameters: | |||
|+ ''params''|Caption | |||
which will generate | |||
<caption ''params''>Caption | |||
==Examples== | |||
=== Simple example === | |||
<nowiki> {| </nowiki> | |||
<nowiki> | Cell 1, row 1 </nowiki> | |||
<nowiki> | Cell 2, row 1 </nowiki> | |||
<nowiki> |- </nowiki><br> | |||
<nowiki> | Cell 1, row 2 </nowiki> | |||
<nowiki> | Cell 2, row 2 </nowiki> | |||
<nowiki> |}</nowiki> | |||
''generates'' | |||
{| | |||
| Cell 1, row 1 | |||
| Cell 2, row 1 | |||
|- | |||
| Cell 1, row 2 | |||
| Cell 2, row 2 | |||
|} | |||
=== Advanced example === | |||
<nowiki>{| align=right border=1</nowiki> | |||
<nowiki>| Cell 1, row 1 </nowiki> | |||
<nowiki>|rowspan=2| Cell 2, row 1 (and 2) </nowiki> | |||
<nowiki>| Cell 3, row 1 </nowiki> | |||
<nowiki>|- </nowiki> | |||
<nowiki>| Cell 1, row 2 </nowiki> | |||
<nowiki>| Cell 3, row 2 </nowiki> | |||
<nowiki>|}</nowiki> | |||
''Note the floating table to the right.'' | |||
{| align=right border=1 | |||
| Cell 1, row 1 | |||
|rowspan=2| Cell 2, row 1 (and 2) | |||
| Cell 3, row 1 | |||
|- | |||
| Cell 1, row 2 | |||
| Cell 3, row 2 | |||
|} | |||
=== Nested table === | |||
<nowiki>{| border=1</nowiki> | |||
<nowiki>| blabla</nowiki> | |||
<nowiki>|</nowiki> | |||
<nowiki>{| bgcolor=#ABCDEF border=2</nowiki> | |||
<nowiki>|nested</nowiki> | |||
<nowiki>|-</nowiki> | |||
<nowiki>|table</nowiki> | |||
<nowiki>|}</nowiki> | |||
<nowiki>|the original table again</nowiki> | |||
<nowiki>|}</nowiki> | |||
''gives a nested table'' | |||
{| border=1 | |||
| blabla | |||
| | |||
{| bgcolor=#ABCDEF border=2 | |||
|nested | |||
|- | |||
|table | |||
|} | |||
|the original table again | |||
|} | |||
=== Caption and multi-cell-lines === | |||
<nowiki>{| border=1</nowiki> | |||
<nowiki>|+ '''This is the caption.''' Example taken from Afghanistan table.</nowiki> | |||
<nowiki>|[[Independence]]||[[August 19]], [[1919]]</nowiki> | |||
<nowiki>|-</nowiki> | |||
<nowiki>|[[Currency]]||[[Afghani]]</nowiki> | |||
<nowiki>|-</nowiki> | |||
<nowiki>|[[Time zone]]||[[UTC]]+4:30</nowiki> | |||
<nowiki>|-</nowiki> | |||
<nowiki>|[[National anthem]]||[[Sououd-e-Melli]]</nowiki> | |||
<nowiki>|-</nowiki> | |||
<nowiki>|[[Top-level domain|Internet TLD]]||.AF</nowiki> | |||
<nowiki>|}</nowiki> | |||
''becomes'' | |||
{| border=1 | |||
|+ '''This is the caption.''' Example taken from Afghanistan table. | |||
|[[Independence]]||[[August 19]], [[1919]] | |||
|- | |||
|[[Currency]]||[[Afghani]] | |||
|- | |||
|[[Time zone]]||[[UTC]]+4:30 | |||
|- | |||
|[[National anthem]]||[[Sououd-e-Melli]] | |||
|- | |||
|[[Top-level domain|Internet TLD]]||.AF | |||
|} | |||
=== Header test === | |||
<nowiki>{| border=1</nowiki> | |||
<nowiki>! Header1!! Header2</nowiki> | |||
<nowiki>|-</nowiki> | |||
<nowiki>| Cell1|| Cell2</nowiki> | |||
<nowiki>|}</nowiki> | |||
''looks like this'' | |||
{| border=1 | |||
! Header1!! Header2 | |||
|- | |||
| Cell1|| Cell2 | |||
|} | |||
== TR test == | |||
<nowiki>{|</nowiki> | |||
<nowiki>| cell1 || cell2</nowiki> | |||
<nowiki>|- bgcolor=#abcdef</nowiki> | |||
<nowiki>| cell3 || cell4</nowiki> | |||
<nowiki>|}</nowiki> | |||
''makes'' | |||
{| | |||
| cell1 || cell2 | |||
|- bgcolor=#abcdef | |||
| cell3 || cell4 | |||
|} | |||
=== Test for rows with mixed headers and body text === | |||
<nowiki>{| border=1 cellspacing=0</nowiki> | |||
<nowiki>! </nowiki> | |||
<nowiki>! col Header1 </nowiki> | |||
<nowiki>! ch2 </nowiki> | |||
<nowiki>|-</nowiki> | |||
<nowiki>! row header 3</nowiki> | |||
<nowiki>| abc def ghi </nowiki> | |||
<nowiki>| gchf ghh dfgh</nowiki> | |||
<nowiki>|-</nowiki> | |||
<nowiki>! RH 4</nowiki> | |||
<nowiki>| gfbb gbgbds </nowiki> | |||
<nowiki>| dfgsdsdg</nowiki> | |||
<nowiki>|}</nowiki> | |||
''makes'' | |||
{| border=1 cellspacing=0 | |||
! | |||
! col Header1 | |||
! ch2 | |||
|- | |||
! row header 3 | |||
| abc def ghi | |||
| gchf ghh dfgh | |||
|- | |||
! RH 4 | |||
| gfbb gbgbds | |||
| dfgsdsdg | |||
|} | |||
'''but:''' | |||
<nowiki>{| border=1 cellspacing=0</nowiki> | |||
<nowiki>! &nbsp; !! col Header1 !! ch2 </nowiki> | |||
<nowiki>|-</nowiki> | |||
<nowiki>! row header 3 || abc def ghi || gchf ghh dfgh</nowiki> | |||
<nowiki>|-</nowiki> | |||
<nowiki>! RH 4 || gfbb gbgbds || dfgsdsdg</nowiki> | |||
<nowiki>|-</nowiki> | |||
<nowiki>! RH 5 || || </nowiki> | |||
<nowiki>|}</nowiki> | |||
''makes'' | |||
{| border=1 cellspacing=0 | |||
! !! col Header1 !! ch2 | |||
|- | |||
! row header 3 || abc def ghi || gchf ghh dfgh | |||
|- | |||
! RH 4 || gfbb gbgbds || dfgsdsdg | |||
|- | |||
! RH 5 || || | |||
|} | |||
Latest revision as of 14:27, 7 June 2007
|
Wiki Manual Getting Started
|
| edit |
Copied From Wikipedia
This new table markup, developed by Magnus Manske, replaces the <table>, <tr>, <td>, <th>, and <caption> HTML tags. The HTML tags can still be used though.
The tags below must start at the beginning of a new line (with one exception). The parameters are optional.
See also: Wiki markup tables
Table
A table is defined by
{| params
|}
which equals
<table params> </table>
- Careful: You must include the space between
{|andparams, or the first parameter gets ignored.
TD
Cells are generated either like this:
|cell1 |cell2 |cell3
or like this:
|cell1||cell2||cell3
which both equals
<td>cell1</td><td>cell2</td><td>cell3</td>
so "||" equals "newline"+"|"
Parameters in cells can be used like this:
|params|cell1
which will result in
<td params>
TH
Functions the same way as TD, except "!" is used instead the opening "|". "!!" can be used instead of "||". Parameters still use "|", though!
TR
<tr> tags will be generated automatically for the first row. To start a new row, use
|-
which results in
<tr>
Parameters can be added like this:
|- params
which results in
<tr params>
Note:
- <tr> tags will be automatically opened at the first <td> equivalent
- <tr> tags will be automatically closed at <tr> and </table> equivalents
CAPTION
A <caption> tag is created by
|+ Caption
which generates
<caption>Caption</caption>
You can also use parameters:
|+ params|Caption
which will generate
<caption params>Caption
Examples
Simple example
{|
| Cell 1, row 1
| Cell 2, row 1
|-
| Cell 1, row 2
| Cell 2, row 2
|}
generates
| Cell 1, row 1 | Cell 2, row 1 |
| Cell 1, row 2 | Cell 2, row 2 |
Advanced example
{| align=right border=1
| Cell 1, row 1
|rowspan=2| Cell 2, row 1 (and 2)
| Cell 3, row 1
|-
| Cell 1, row 2
| Cell 3, row 2
|}
Note the floating table to the right.
| Cell 1, row 1 | Cell 2, row 1 (and 2) | Cell 3, row 1 |
| Cell 1, row 2 | Cell 3, row 2 |
Nested table
{| border=1
| blabla
|
{| bgcolor=#ABCDEF border=2
|nested
|-
|table
|}
|the original table again
|}
gives a nested table
| blabla |
|
the original table again |
Caption and multi-cell-lines
{| border=1
|+ '''This is the caption.''' Example taken from Afghanistan table.
|[[Independence]]||[[August 19]], [[1919]]
|-
|[[Currency]]||[[Afghani]]
|-
|[[Time zone]]||[[UTC]]+4:30
|-
|[[National anthem]]||[[Sououd-e-Melli]]
|-
|[[Top-level domain|Internet TLD]]||.AF
|}
becomes
| Independence | August 19, 1919 |
| Currency | Afghani |
| Time zone | UTC+4:30 |
| National anthem | Sououd-e-Melli |
| Internet TLD | .AF |
Header test
{| border=1
! Header1!! Header2
|-
| Cell1|| Cell2
|}
looks like this
| Header1 | Header2 |
|---|---|
| Cell1 | Cell2 |
TR test
{|
| cell1 || cell2
|- bgcolor=#abcdef
| cell3 || cell4
|}
makes
| cell1 | cell2 |
| cell3 | cell4 |
Test for rows with mixed headers and body text
{| border=1 cellspacing=0
!
! col Header1
! ch2
|-
! row header 3
| abc def ghi
| gchf ghh dfgh
|-
! RH 4
| gfbb gbgbds
| dfgsdsdg
|}
makes
| col Header1 | ch2 | |
|---|---|---|
| row header 3 | abc def ghi | gchf ghh dfgh |
| RH 4 | gfbb gbgbds | dfgsdsdg |
but:
{| border=1 cellspacing=0
! !! col Header1 !! ch2
|-
! row header 3 || abc def ghi || gchf ghh dfgh
|-
! RH 4 || gfbb gbgbds || dfgsdsdg
|-
! RH 5 || ||
|}
makes
| col Header1 | ch2 | |
|---|---|---|
| row header 3 | abc def ghi | gchf ghh dfgh |
| RH 4 | gfbb gbgbds | dfgsdsdg |
| RH 5 |