Help:Table: Difference between revisions

From the Nintendo Wiki, a wiki covering all things Nintendo
Jump to navigationJump to search
Content added Content deleted
(from https://www.mariowiki.com/Help:Table)
 
Line 1: Line 1:
The following shows you how to create a '''table'''.
'''Tables''' can be used for displaying data and for creating box-type designs for pages on this wiki.


== MediaWiki syntax ==
==Markup==
To create a table, you will first need to understand the basic wikitext syntax:
There are many ways to create a table. Below shows the most basic example of creating a table, but users are asked to add either <code>class="table"</code> (for black borders) or <code>class="wikitable"</code> (a predetermined format by the MediaWiki software that gives it gray borders and headers) after the <code>{|</code>.


*<code><nowiki>{|</nowiki></code> - Signifies the start of a table.
{|
*<code><nowiki>|+</nowiki></code> - Signifies the caption of a table; what text will appear above it, labeling it.
|-
*<code><nowiki>!</nowiki></code> - Signifies the start of a header table cell. The text within a header cell is boldfaced and centered.
!&nbsp;
*<code><nowiki>!!</nowiki></code> - Signifies the switch to a new header cell within a row.
!XHTML
*<code><nowiki>|-</nowiki></code> - Signifies the start of a table row.
!Wiki syntax
*<code><nowiki>|</nowiki></code> - Signifies the start of a regular table cell.
|-
*<code><nowiki>||</nowiki></code> - Signifies the switch to a new cell within a row.
!Table
*<code><nowiki>|}</nowiki></code> - Signifies the end of a table.
|<nowiki><table></table></nowiki>
|<pre><nowiki>{| params
|}</nowiki></pre>


=== Usage ===
|-
Here is an example of how the syntax is combined to create a table:

!Caption
|<nowiki><caption></caption></nowiki>
|<pre><nowiki>|+ caption</nowiki></pre>

|-
!Row
|<nowiki><tr></tr></nowiki>
|<pre><nowiki>|- params </nowiki></pre>

|-
!Data cell
|<nowiki><td>cell1</td></nowiki><br />
<nowiki><td>cell2</td></nowiki>
|
<pre><nowiki>| cell1
| cell2</nowiki></pre>

|-
!Data cell
|<nowiki><td>cell1</td> <td>cell2</td> <td>cell3</td></nowiki>
|<pre><nowiki>|cell1||cell2||cell3</nowiki></pre>

|-
!Header cell
|<nowiki><th></th></nowiki>
|<pre><nowiki>! heading</nowiki></pre>
|}

You can add "sortable" within the class (e.g. <code>class="wikitable sortable</code>) to add arrows, allowing you to sort certain table columns.

==Sample tables==
{|
| 1 || 2
|-
| 3 || 4
|}


<pre>
{|
{|
|+ This is the caption for my table.
! These !! are !! my !! table !! headers
|-
|-
| These || are || my || regular || cells
!XHTML
!Wiki syntax
|-
|-
| These || are || my || regular || cells
|<pre><nowiki>
<table>
<tr>
<td>1</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>4</td>
</tr>
</table>
</nowiki></pre>

|<pre><nowiki>
{|
| 1 || 2
|-
| 3 || 4
|}</nowiki></pre>
|}
|}
</pre>


== Table types ==
With the "table" class applied:
=== Standard table ===
Add <code>class="wikitable"</code> right after the start of the table to apply the appropriate wiki styling:


{| class="table"
<pre>{| class="wikitable"</pre>
| 1 || 2
|-
| 3 || 4
|}


Some additional table classes that can be added are:
With the "wikitable" class applied:


*<code>dk</code> - Applies a ''[[Donkey Kong (franchise)|Donkey Kong]]'' theme to the wikitable.
{| class="wikitable"
*<code>center</code> - Centers the table in the middle of the page.
| 1 || 2
*<code>sortable</code> - Adds JavaScript sorting to the table headers.
|-
*<code>scrollable</code> - Adds horizontal scrolling to extra-wide tables.
| 3 || 4
*<code>autoresize</code> - Automatically downscales images in cramped tables.
|}


Multiple classes are simply separated by a space. For example:
{|
!Table
!Wikitable
|-
|<pre>
{| class="table"
| 1 || 2
|-
| 3 || 4
|}</pre>
|<pre>
{| class="wikitable"
| 1 || 2
|-
| 3 || 4
|}</pre>
|}


<pre>{| class="wikitable dk sortable"</pre>
==Notes==
* The entire table begins with <code>{|</code> and ends with the required <code>|}</code>.
* A '''caption''' is a succinct way to describe your table, and can be included with <code>|+</code> on the line after <code>{|</code>.
* '''Table rows''' are horizontal groups of cells in the table. A row begins with <code>|-</code> and ends at the next row.
* '''Table headings''' are cells with headings in them, and are often rendered in a bold font. They begin with <code>!</code>. Note that parameters are still separated from the actual content of the cell with <code>|</code>, however
* '''Table data''' cells fill out the rest of the table. A cell begins with <code>|</code> or <code>||</code> and ends at the next cell.


==== Example ====
Each row must have the same number of cells as the other rows, so that the number of columns in the table remains consistent (unless there are cells which span several columns or rows, but this is not discussed here). For empty cells, use the non-breaking space <code>&amp;nbsp;</code> as content to ensure that the cells are displayed.
{| class="wikitable sortable"

! #
==Complex layout (made simple)==
! Preview
This advanced example shows some of the options available for making tables. Users are advised to '''not''' add this in articles, as several of these options are already incorporated in the "table" class (which is has been defined in [[MediaWiki:Common.css|Common.css]]). You can play with these settings in your own table to see what effect they have. Not all of these techniques may be appropriate in all cases; just because you can add colored backgrounds, for example, doesn't mean it's always a good idea. Try to keep the markup in your tables relatively simple &mdash; remember, other people are going to be editing the page too.
! Event

! Player's characters
{| border="1" cellpadding="5" cellspacing="0" width="330" style="border-collapse:collapse;"
! In-game description
|+'''An example layout'''
! Stage
|-
|-
! 1
! style="background:#efefef; color:#000;" | First header
| [[File:Events01.png|100px]]
! colspan="2" style="background:#ffdead; color:#000;" | Second header
| Two Trouble Kings
| [[Mario]] and [[Kirby]]
| ''Now there are TWO greedy kings? Having a buddy doesn't change their natures.'' (KO Bowser and King Dedede)
| [[Delfino Plaza]]
|-
|-
! 2
| upper left
| [[File:C-02.png|100px]]
| &nbsp;
| Master the Pokémon Tag Battle
| rowspan=2 | right side
| [[Pokémon Trainer]] and [[Pikachu]]
|-
| ''The Pokemon tournament's final challenge. Your rivals have the same Pokemon!'' (KO rival Pokemon Trainer, and Pikachu)
| | lower left
| [[Pokémon Stadium 2]]
| | lower middle
|}

{| style="border:1px solid; border-top:none; width:330px;"
|-
|-
! 3
|| [[File:Example.png]]
|| [[File:Example.png]]
| [[File:C-03.png|100px]]
| Fastest, Shortest, Sudden Death
| [[Yoshi]] and [[King Dedede]]
| ''Only ten seconds left?! Beat as many foes as you can in Super Sudden Death and live!'' (survive 10 seconds at 300% damage)
| [[WarioWare, Inc. (stage)|WarioWare, Inc.]]
|-
|-
! 4
| align="center" colspan="2"|
| [[File:C-04.png|100px]]
<div style="border:1px solid red;">Welcome gamers</div>
| The DK Tag Calamity
| [[Donkey Kong]] and [[Diddy Kong]]
| ''DK and Diddy got tiny! Use lightning to help deal the final blow!'' (defeat all enemies while many Lightning Bolt items appear)
| [[Mario Circuit]]
|}
|}


Here is the source code for the above table:
Your table code reflect the table structure. Although it is possible to compose complex layout as one table, it is generally not advisable. For simplicity, it is best to split the layout into small units.


<pre>
=== Split it up ===
{| class="wikitable sortable"
While you can nest table
! #

! Preview
{|
! Event
!layout
! Player's characters
!code
! In-game description
! Stage
|-
|-
! 1
||
| [[File:Events01.png|100px]]
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse;" width="330"
| Two Trouble Kings
|+'''An example layout'''
| [[Mario]] and [[Kirby]]
| ''Now there are TWO greedy kings? Having a buddy doesn't change their natures.'' (KO Bowser and King Dedede)
| [[Delfino Plaza]]
|-
|-
! 2
! First header
| [[File:C-02.png|100px]]
! colspan="2" | Second header
| Master the Pokémon Tag Battle
| [[Pokémon Trainer]] and [[Pikachu]]
| ''The Pokemon tournament's final challenge. Your rivals have the same Pokemon!'' (KO rival Pokemon Trainer, and Pikachu)
| [[Pokémon Stadium 2]]
|-
|-
! 3
| upper left
| [[File:C-03.png|100px]]
| &nbsp;
| Fastest, Shortest, Sudden Death
| rowspan=2 | right side
| [[Yoshi]] and [[King Dedede]]
| ''Only ten seconds left?! Beat as many foes as you can in Super Sudden Death and live!'' (survive 10 seconds at 300% damage)
| [[WarioWare, Inc. (stage)|WarioWare, Inc.]]
|-
|-
! 4
| | lower left
| [[File:C-04.png|100px]]
| | lower middle
| The DK Tag Calamity
|-
| [[Donkey Kong]] and [[Diddy Kong]]
| colspan="3" |
| ''DK and Diddy got tiny! Use lightning to help deal the final blow!'' (defeat all enemies while many Lightning Bolt items appear)
{| border="0"
| [[Mario Circuit]]
|+''A table in a table''
|-
|| [[File:Example.png]]
|| [[File:Example.png]]
|}
|}
|}
</pre>


=== Responsive table ===
||<pre><nowiki>
Responsive tables look just like standard tables on wider desktop displays, but on narrow mobile displays they transform to show each row individually, with a given label for each cell.
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse;" width="330"
|+'''An example layout'''
|-
! First header
! colspan="2" | Second header
|-
| upper left
| &nbsp;
| rowspan=2 | right side
|-
| | lower left
| | lower middle
|-
| colspan="3" align="center" |
{| border="0"
|+''A table in a table''
|-
|| [[File:Example.png]]
|| [[File:Example.png]]
|}
|}</nowiki></pre>
|}


To create a responsive table, the first step is to add the <code>responsive</code> class to the table:
It may be better to split the tables up:


<pre>{| class="wikitable responsive"</pre>
{|
!layout
!code
|-
||
{| border="1" cellpadding="5" cellspacing="0" width="330" style="border-collapse:collapse;"
|+'''An example layout'''
|-
! First header
! colspan="2" | Second header
|-
| upper left
| &nbsp;
| rowspan=2 | right side
|-
| | lower left
| | lower middle
|}


And then you add the <code>data-label</code> to each table cell (typically the same label used in the header):
{| style="border:1px solid; border-top:none; width:330px;"
|-
|| [[File:Example.png]]
|| [[File:Example.png]]
|}
||<pre><nowiki>
{| border="1" cellpadding="5" cellspacing="0" width="330" style="border-collapse:collapse;"
|+'''An example layout'''
|-
! First header
! colspan="2" | Second header
|-
| upper left
| &nbsp;
| rowspan=2 | right side
|-
| | lower left
| | lower middle
|}


<pre>| data-label="Answer 1" | Your wish is granted.</pre>
{| style="border:1px solid; border-top:none; width:330px;"
|-
|| [[File:Example.png]]
|| [[File:Example.png]]
|}</nowiki></pre>
|}


==== Example ====
=== Don't use table for simple box ===
{| class="wikitable responsive"
Table code should be used for tables only. For simple boxes, use <code>&lt;div&gt;&lt;/div&gt;</code> instead. For example, instead of:
! #

! Question
{|
! Answer 1
!layout
! Answer 2
!code
! Answer 3
|-
! data-label="#" | 1
| data-label="Question" | What will happen if you collect seven [[Crystal Stars]]?
| data-label="Answer 1" | Your wish is granted.
| data-label="Answer 2" | [[The Thousand-Year Door]] opens.
| data-label="Answer 3" | A thousand [[coin]]s appear.
|-
|-
! data-label="#" | 2
||
| data-label="Question" | What is the goal of [[Sir Grodus|Grodus]], leader of the [[X-Nauts (organization)|X-Nauts]]?
{| style="border:1px solid; border-top:none; width:330px;"
| data-label="Answer 1" | To conquer the world.
| data-label="Answer 2" | To get rich.
| data-label="Answer 3" | To become a superhero.
|-
|-
! data-label="#" | 3
|| [[File:Example.png]]
| data-label="Question" | What is the legendary treasure that waits behind the Thousand-Year Door?
|| [[File:Example.png]]
| data-label="Answer 1" | 100,000,000 coins.
| data-label="Answer 2" | An extremely rare [[badge]].
| data-label="Answer 3" | A 1,000-year-old [[Shadow Queen|demon]]'s soul.
|-
|-
! data-label="#" | 4
| align="center" colspan="2" style="border:1px solid red;" |
| data-label="Question" | What does Sir Grodus wish to do with this ancient demon's soul?
Welcome gamers
| data-label="Answer 1" | Cherish it always.
|}
| data-label="Answer 2" | Bring the demon back to life.
||<pre><nowiki>
| data-label="Answer 3" | Hang out with it.
{| style="border:1px solid; border-top:none; width:330px;"
|-
|| [[File:Example.png]]
|| [[File:Example.png]]
|-
| align="center" colspan="2" style="border-top:1px solid red;"|
Welcome gamers
|}</nowiki></pre>
|}
|}


Here is the source code for the above table:
You may use


<pre>
{|
{| class="wikitable responsive"
!layout
! #
!code
! Question
! Answer 1
! Answer 2
! Answer 3
|-
! data-label="#" | 1
| data-label="Question" | What will happen if you collect seven [[Crystal Stars]]?
| data-label="Answer 1" | Your wish is granted.
| data-label="Answer 2" | [[The Thousand-Year Door]] opens.
| data-label="Answer 3" | A thousand [[coin]]s appear.
|-
|-
! data-label="#" | 2
||
| data-label="Question" | What is the goal of [[Sir Grodus|Grodus]], leader of the [[X-Nauts (organization)|X-Nauts]]?
{| style="border:1px solid; border-top:none; width:330px;"
| data-label="Answer 1" | To conquer the world.
| data-label="Answer 2" | To get rich.
| data-label="Answer 3" | To become a superhero.
|-
|-
! data-label="#" | 3
|| [[File:Example.png]]
| data-label="Question" | What is the legendary treasure that waits behind the Thousand-Year Door?
|| [[File:Example.png]]
| data-label="Answer 1" | 100,000,000 coins.
| data-label="Answer 2" | An extremely rare [[badge]].
| data-label="Answer 3" | A 1,000-year-old [[Shadow Queen|demon]]'s soul.
|-
|-
! data-label="#" | 4
| align="center" colspan="2"|
| data-label="Question" | What does Sir Grodus wish to do with this ancient demon's soul?
<div style="border:1px solid red;">Welcome gamers</div>
| data-label="Answer 1" | Cherish it always.
|}
| data-label="Answer 2" | Bring the demon back to life.
||<pre><nowiki>
| data-label="Answer 3" | Hang out with it.
{| style="border:1px solid; border-top:none; width:330px;"
|-
|| [[File:Example.png]]
|| [[File:Example.png]]
|-
| align="center" colspan="2"|
<div style="border:1px solid red;">Welcome gamers</div>
|}</nowiki></pre>
|}
|}
</pre>


=== The complete code ===
== Style tweaks ==
A table's <code>style</code> attribute can be used to make additional adjustments to the wikitable format. Here are two of the most basic style changes:


;Adjust the table's width
{| border="1" cellpadding="5" cellspacing="0" width="330" style="border-collapse:collapse;"
:<code>style="width:50%"</code>
|+'''An example layout'''
|-
! style="background:#efefef; color:#000;" | First header
! colspan="2" style="background:#ffdead; color:#000;" | Second header
|-
| upper left
| &nbsp;
| rowspan=2 | right side
|-
| | lower left
| | lower middle
|}


;Center all text within the table
{| style="border:1px solid; border-top:none; width:330px;"
:<code>style="text-align:center"</code>
|-
|| [[File:Example.png]]
|| [[File:Example.png]]
|-
| align="center" colspan="2"|
<div style="border:1px solid red;">Welcome gamers</div>
|}


Multiple properties are separated by the <code>;</code> character. Here's what the start of a table might look like with these properties applied:
<pre><nowiki>
{| border="1" cellpadding="5" cellspacing="0" width="330" style="border-collapse:collapse;"
|+'''An example layout'''
|-
! style="background:#efefef; color:#000;" | First header
! colspan="2" style="background:#ffdead; color:#000;" | Second header
|-
| upper left
| &nbsp;
| rowspan=2 | right side
|-
| | lower left
| | lower middle
|}


<pre>{| class="wikitable center" style="width:50%; text-align:center"</pre>
{| style="border:1px solid; border-top:none; width:330px;"
|-
|| [[File:Example.png]]
|| [[File:Example.png]]
|-
| align="center" colspan="2"|
<div style="border:1px solid red;">Welcome gamers</div>
|}
</nowiki></pre>


For most conventional tables like the examples in the above section, no style changes are needed.
==Attribution==
The original policy page was from [https://web.archive.org/web/20080105114847/http://www.wikia.com/wiki/Help:Table Wikia Central].


{{Nintendo Wiki}}
{{Shortcut|NW:TABLE}}
[[Category:Help]]
[[Category:Help]]

Latest revision as of 23:45, February 16, 2024

The following shows you how to create a table.

MediaWiki syntax[edit]

To create a table, you will first need to understand the basic wikitext syntax:

  • {| - Signifies the start of a table.
  • |+ - Signifies the caption of a table; what text will appear above it, labeling it.
  • ! - Signifies the start of a header table cell. The text within a header cell is boldfaced and centered.
  • !! - Signifies the switch to a new header cell within a row.
  • |- - Signifies the start of a table row.
  • | - Signifies the start of a regular table cell.
  • || - Signifies the switch to a new cell within a row.
  • |} - Signifies the end of a table.

Usage[edit]

Here is an example of how the syntax is combined to create a table:

{|
|+ This is the caption for my table.
! These !! are !! my !! table !! headers
|-
| These || are || my || regular || cells
|-
| These || are || my || regular || cells
|}

Table types[edit]

Standard table[edit]

Add class="wikitable" right after the start of the table to apply the appropriate wiki styling:

{| class="wikitable"

Some additional table classes that can be added are:

  • dk - Applies a Donkey Kong theme to the wikitable.
  • center - Centers the table in the middle of the page.
  • sortable - Adds JavaScript sorting to the table headers.
  • scrollable - Adds horizontal scrolling to extra-wide tables.
  • autoresize - Automatically downscales images in cramped tables.

Multiple classes are simply separated by a space. For example:

{| class="wikitable dk sortable"

Example[edit]

# Preview Event Player's characters In-game description Stage
1 File:Events01.png Two Trouble Kings Mario and Kirby Now there are TWO greedy kings? Having a buddy doesn't change their natures. (KO Bowser and King Dedede) Delfino Plaza
2 File:C-02.png Master the Pokémon Tag Battle Pokémon Trainer and Pikachu The Pokemon tournament's final challenge. Your rivals have the same Pokemon! (KO rival Pokemon Trainer, and Pikachu) Pokémon Stadium 2
3 File:C-03.png Fastest, Shortest, Sudden Death Yoshi and King Dedede Only ten seconds left?! Beat as many foes as you can in Super Sudden Death and live! (survive 10 seconds at 300% damage) WarioWare, Inc.
4 File:C-04.png The DK Tag Calamity Donkey Kong and Diddy Kong DK and Diddy got tiny! Use lightning to help deal the final blow! (defeat all enemies while many Lightning Bolt items appear) Mario Circuit

Here is the source code for the above table:

{| class="wikitable sortable"
! #
! Preview
! Event
! Player's characters
! In-game description
! Stage
|-
! 1
| [[File:Events01.png|100px]]
| Two Trouble Kings
| [[Mario]] and [[Kirby]]
| ''Now there are TWO greedy kings? Having a buddy doesn't change their natures.'' (KO Bowser and King Dedede)
| [[Delfino Plaza]]
|-
! 2
| [[File:C-02.png|100px]]
| Master the Pokémon Tag Battle
| [[Pokémon Trainer]] and [[Pikachu]]
| ''The Pokemon tournament's final challenge. Your rivals have the same Pokemon!'' (KO rival Pokemon Trainer, and Pikachu)
| [[Pokémon Stadium 2]]
|-
! 3
| [[File:C-03.png|100px]]
| Fastest, Shortest, Sudden Death
| [[Yoshi]] and [[King Dedede]]
| ''Only ten seconds left?! Beat as many foes as you can in Super Sudden Death and live!'' (survive 10 seconds at 300% damage)
| [[WarioWare, Inc. (stage)|WarioWare, Inc.]]
|-
! 4
| [[File:C-04.png|100px]]
| The DK Tag Calamity
| [[Donkey Kong]] and [[Diddy Kong]]
| ''DK and Diddy got tiny! Use lightning to help deal the final blow!'' (defeat all enemies while many Lightning Bolt items appear)
| [[Mario Circuit]]
|}

Responsive table[edit]

Responsive tables look just like standard tables on wider desktop displays, but on narrow mobile displays they transform to show each row individually, with a given label for each cell.

To create a responsive table, the first step is to add the responsive class to the table:

{| class="wikitable responsive"

And then you add the data-label to each table cell (typically the same label used in the header):

| data-label="Answer 1" | Your wish is granted.

Example[edit]

# Question Answer 1 Answer 2 Answer 3
1 What will happen if you collect seven Crystal Stars? Your wish is granted. The Thousand-Year Door opens. A thousand coins appear.
2 What is the goal of Grodus, leader of the X-Nauts? To conquer the world. To get rich. To become a superhero.
3 What is the legendary treasure that waits behind the Thousand-Year Door? 100,000,000 coins. An extremely rare badge. A 1,000-year-old demon's soul.
4 What does Sir Grodus wish to do with this ancient demon's soul? Cherish it always. Bring the demon back to life. Hang out with it.

Here is the source code for the above table:

{| class="wikitable responsive"
! #
! Question
! Answer 1
! Answer 2
! Answer 3
|-
! data-label="#" | 1
| data-label="Question" | What will happen if you collect seven [[Crystal Stars]]?
| data-label="Answer 1" | Your wish is granted.
| data-label="Answer 2" | [[The Thousand-Year Door]] opens.
| data-label="Answer 3" | A thousand [[coin]]s appear.
|-
! data-label="#" | 2
| data-label="Question" | What is the goal of [[Sir Grodus|Grodus]], leader of the [[X-Nauts (organization)|X-Nauts]]?
| data-label="Answer 1" | To conquer the world.
| data-label="Answer 2" | To get rich.
| data-label="Answer 3" | To become a superhero.
|-
! data-label="#" | 3
| data-label="Question" | What is the legendary treasure that waits behind the Thousand-Year Door?
| data-label="Answer 1" | 100,000,000 coins.
| data-label="Answer 2" | An extremely rare [[badge]].
| data-label="Answer 3" | A 1,000-year-old [[Shadow Queen|demon]]'s soul.
|-
! data-label="#" | 4
| data-label="Question" | What does Sir Grodus wish to do with this ancient demon's soul?
| data-label="Answer 1" | Cherish it always.
| data-label="Answer 2" | Bring the demon back to life.
| data-label="Answer 3" | Hang out with it.
|}

Style tweaks[edit]

A table's style attribute can be used to make additional adjustments to the wikitable format. Here are two of the most basic style changes:

Adjust the table's width
style="width:50%"
Center all text within the table
style="text-align:center"

Multiple properties are separated by the ; character. Here's what the start of a table might look like with these properties applied:

{| class="wikitable center" style="width:50%; text-align:center"

For most conventional tables like the examples in the above section, no style changes are needed.