Help:Tables: Difference between revisions

Help page
m (→‎Removing cell borders: blank section)
m (fixed link)
 
Line 208: Line 208:
|-
|-
! style="width: 3em;" | [[File:Advocate.png|x35px|link=Advocate]]
! style="width: 3em;" | [[File:Advocate.png|x35px|link=Advocate]]
! style="width: 3em;" | [[File:PKR Maelstrom.png|x35px|link=Maelstrom]]
! style="width: 3em;" | [[File:PKR Maelstrom.png|x35px|link=PKR Maelstrom]]
|-
|-
| Foo
| Foo
Line 242: Line 242:
|-
|-
! style="width: 3em;" | [[File:Advocate.png|x35px|link=Advocate]]
! style="width: 3em;" | [[File:Advocate.png|x35px|link=Advocate]]
! style="width: 3em;" | [[File:PKR Maelstrom.png|x35px|link=Maelstrom]]
! style="width: 3em;" | [[File:PKR Maelstrom.png|x35px|link=PKR Maelstrom]]
|-
|-
| Foo
| Foo

Latest revision as of 22:42, 25 June 2023

This page explains the use of wikitables.

If you are still stuck, Wikipedia has a large help page on tables.

Standard table examples

{| class="wikitable"
|-
! Header 1
! Header 2
! Header 3
|-
| row 1, cell 1
| row 1, cell 2
| row 1, cell 3
|-
| row 2, cell 1
| row 2, cell 2
| row 2, cell 3
|}

This code produces the following table:

Header 1 Header 2 Header 3
row 1, cell 1 row 1, cell 2 row 1, cell 3
row 2, cell 1 row 2, cell 2 row 2, cell 3

{| class="wikitable"
|+ The table's caption
! Column header 1
! Column header 2
! Column header 3
|-
! Row header 1
| Cell 2 || Cell 3
|-
! Row header A
| Cell B
| Cell C
|}

This code produces the following table:

The table's caption
Column header 1 Column header 2 Column header 3
Row header 1 Cell 2 Cell 3
Row header A Cell B Cell C


{| class="wikitable" style="text-align: center; width: 200px; height: 200px;"
|+ Multiplication table
|-
! ×
! 1
! 2
! 3
|-
! 1
| 1 || 2 || 3
|-
! 2
| 2 || 4 || 6
|-
! 3
| 3 || 6 || 9
|-
! 4
| 4 || 8 || 12
|-
! 5
| 5 || 10 || 15
|}

This code produces the following table:

Multiplication table
× 1 2 3
1 1 2 3
2 2 4 6
3 3 6 9
4 4 8 12
5 5 10 15


{| class="wikitable"
|-
! Column 1<br />(row 1 cell 1) !! Column 2<br />(row 1 cell 2) !! Column 3<br />(row 1 cell 3)
|-
| rowspan="2" | A<br />(row 2 cell 1)<br /><code>rowspan="2"</code>
| colspan="2" style="text-align: center;" | B<br />(row 2 cell 2)<br /><code>colspan="2"</code>
|-
| C<br />(row 3 cell 1) <!-- column 1 occupied by cell A -->
| D<br />(row 3 cell 2)
|-
| E<br />(row 4 cell 1)
| rowspan="2" colspan="2" style="text-align: center;" |F<br />(row 4 cell 2)<br /><code>rowspan="2" colspan="2"</code>
|-
| G<br />(row 5 cell 1) <!-- column 2+3 occupied by cell F -->
|-
| colspan="3" style="text-align: center;" | H<br />(row 6 cell 1)<br /><code>colspan="3"</code>
|}

This code produces the following table:

Column 1
(row 1 cell 1)
Column 2
(row 1 cell 2)
Column 3
(row 1 cell 3)
A
(row 2 cell 1)
rowspan="2"
B
(row 2 cell 2)
colspan="2"
C
(row 3 cell 1)
D
(row 3 cell 2)
E
(row 4 cell 1)
F
(row 4 cell 2)
rowspan="2" colspan="2"
G
(row 5 cell 1)
H
(row 6 cell 1)
colspan="3"

Collapsible tables

Adding mw-collapsible to the table's class will make it collapsible. A further parameter of mw-collapsed will set it collapsed by default and omitting it keeps the table shown by default.

{| class="mw-collapsible mw-collapsed wikitable"
|+ Caption
! Column header 1
! Column header 2
|-
! Row header 1
| Cell 2
|-
! Row header A
| Cell B
|}

This code produces the following table:

Caption
Column header 1 Column header 2
Row header 1 Cell 2
Row header A Cell B

Styling

Tables can be styled by using the CSS classes shown here.

class="wikitable"
Foo Bar FooBar
Advocate.png PKR Maelstrom.png
Foo Bar FooBar
Foo Bar FooBar
Foo Bar FooBar
Foo Bar FooBar


Alternating row colors

Add zebra to alternate the color of each (non-header) row.

class="wikitable zebra"
Foo Bar FooBar
Advocate.png PKR Maelstrom.png
Foo Bar FooBar
Foo Bar FooBar
Foo Bar FooBar
Foo Bar FooBar
class="wikitable zebra"
Cookies help us deliver our services. By using our services, you agree to our use of cookies.