Locked
Halopedia

Help:Tables: Difference between revisions

From Halopedia, the Halo wiki

m (sort in category)
m (Bot: Automated text replacement (-^ +{{Status|Halopedia}}\n))
 
(9 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{Status|Halopedia}}
== Introduction ==
== Introduction ==
 
In Halopedia you can create a table by using the HTML code.  However, Halopedia offers a simpler way to create a table.  If you have a table in HTML that you want to convert to a wiki-table please refer to the [[wikipedia:Help:Table#External links|Wiki-Table generators]].  
In Halopedia you can create a table by using the HTML code.  However, Halopedia offers a simpler way to create a table.  If you have a table in HTML that you want to convert to a wiki-tablei please refer to the [[Wikipedia:Help:Table#External links|Wiki-Table generators]].  


== Pipe syntax tutorial ==
== Pipe syntax tutorial ==
The Wiki table using the | or pipe sign as a way to create a table.  Below is an example and explanation of how to create a table.
The Wiki table using the | or pipe sign as a way to create a table.  Below is an example and explanation of how to create a table.
* The entire table is encased with curly brackets and a [[wikipedia:vertical bar|vertical bar]] character (a pipe).  So use <code>'''{|'''</code> to begin a table, and <code>'''|}'''</code> to end it.  Each one needs to be on its own line:  
* The entire table is encased with curly brackets and a [[wikipedia:vertical bar|vertical bar]] character (a pipe).  So use <code>'''{|'''</code> to begin a table, and <code>'''|}'''</code> to end it.  Each one needs to be on its own line:  
Line 77: Line 76:
  <nowiki>|}</nowiki>
  <nowiki>|}</nowiki>
The final table would display like this:
The final table would display like this:
<blockquote style="background: white; border: 2px solid rgb(153, 153, 153); padding: 1em;">
<blockquote style="border: 2px solid rgb(153, 153, 153); padding: 1em;">
{| border="1"
{| border="1"
|+ The table's caption
|+ The table's caption
Line 91: Line 90:
The table parameters and cell parameters are the same as in HTML, see  [http://www.w3.org/TR/html401/struct/tables.html#edef-TABLE] and  [[wikipedia:HTML element#Tables|HTML element#Tables]].  
The table parameters and cell parameters are the same as in HTML, see  [http://www.w3.org/TR/html401/struct/tables.html#edef-TABLE] and  [[wikipedia:HTML element#Tables|HTML element#Tables]].  


A table can be useful even if none of the cells have content.  For example, the background colors of cells can be changed with cell parameters, making the table into a diagram, like [[m:Template talk:Square 8x8 pentomino example]].  An "image" in the form of a table is much more convenient to edit than an uploaded image.
A table can be useful even if none of the cells have content.  For example, the background colors of cells can be changed with cell parameters, making the table into a diagram.  An "image" in the form of a table is much more convenient to edit than an uploaded image.


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, see colspan and rowspan in M&#233;lange example below). For empty cells, use the non-breaking space <code>&amp;nbsp;</code> as content to ensure that the cells are displayed.
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, see colspan and rowspan in M&#233;lange example below). For empty cells, use the non-breaking space <code>&amp;nbsp;</code> as content to ensure that the cells are displayed.
Line 99: Line 98:
=== Simple example ===
=== Simple example ===
Both of these generate the same output.  Choose a style based on the amount of cells in each row and the total text inside each cell.
Both of these generate the same output.  Choose a style based on the amount of cells in each row and the total text inside each cell.
'''Wiki markup'''
==== Wiki markup ====
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre><nowiki>
<blockquote style="border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre><nowiki>
{|  
{|  
| Cell 1, row 1  
| Cell 1, row 1  
Line 109: Line 108:
|}
|}
</nowiki></pre></blockquote>
</nowiki></pre></blockquote>
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre><nowiki>
<blockquote style="border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre><nowiki>
{|  
{|  
| Cell 1, row 1 || Cell 2, row 1  
| Cell 1, row 1 || Cell 2, row 1  
Line 116: Line 115:
|}
|}
</nowiki></pre></blockquote>
</nowiki></pre></blockquote>
'''What it looks like in your browser'''
==== What it looks like in your browser ====
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;">
<blockquote style="border: 1px solid rgb(153, 153, 153); padding: 1em;">
{|  
{|  
| Cell 1, row 1  
| Cell 1, row 1  
Line 127: Line 126:
</blockquote>
</blockquote>
===Multiplication table===
===Multiplication table===
'''Wiki markup'''
==== Wiki markup ====
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre><nowiki>
<blockquote style="border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre><nowiki>
{| class="wikitable" style="text-align:center"
{| class="wikitable" style="text-align:center"
|+Multiplication table
|+Multiplication table
Line 150: Line 149:
|}
|}
</nowiki></pre></blockquote>
</nowiki></pre></blockquote>
'''What it looks like in your browser'''
==== What it looks like in your browser ====
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;">
<blockquote style="border: 1px solid rgb(153, 153, 153); padding: 1em;">
{| class="wikitable" style="text-align:center"
{| class="wikitable" style="text-align:center"
|+Multiplication table
|+Multiplication table
Line 175: Line 174:
===Color; scope of parameters===
===Color; scope of parameters===
Two ways of specifying color of text and background for a single cell are as follows.  The first form is preferred:
Two ways of specifying color of text and background for a single cell are as follows.  The first form is preferred:
'''Wiki markup'''
==== Wiki markup ====
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre><nowiki>
<blockquote style="border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre><nowiki>
{|  
{|  
| style="background:red; color:white" | abc
| style="background:red; color:white" | abc
Line 184: Line 183:
|}
|}
</nowiki></pre></blockquote>
</nowiki></pre></blockquote>
'''What it looks like in your browser'''
==== What it looks like in your browser ====
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;">
<blockquote style="border: 1px solid rgb(153, 153, 153); padding: 1em;">
{|  
{|  
| style="background:red; color:white" | abc
| style="background:red; color:white" | abc
Line 194: Line 193:
</blockquote>
</blockquote>
Like other parameters, colors can also be specified for a whole row or the whole table; parameters for a row override the value for the table, and those for a cell override those for a row:
Like other parameters, colors can also be specified for a whole row or the whole table; parameters for a row override the value for the table, and those for a cell override those for a row:
'''Wiki markup'''
==== Wiki markup ====
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre><nowiki>
<blockquote style="border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre><nowiki>
{| style="background:yellow; color:green"
{| style="background:yellow; color:green"
|-  
|-  
Line 211: Line 210:
|}
|}
</nowiki></pre></blockquote>
</nowiki></pre></blockquote>
'''What it looks like in your browser'''
==== What it looks like in your browser ====
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;">
<blockquote style="border: 1px solid rgb(153, 153, 153); padding: 1em;">
{| style="background:yellow; color:green"
{| style="background:yellow; color:green"
|-  
|-  
Line 231: Line 230:
===Width, height===
===Width, height===
The width and height of the whole table can be specified, as well as the height of a row. To specify the width of a column one can specify the width of an arbitrary cell in it. If the width is not specified for all columns, and/or the height is not specified for all rows, then there is some ambiguity, and the result depends on the browser.  
The width and height of the whole table can be specified, as well as the height of a row. To specify the width of a column one can specify the width of an arbitrary cell in it. If the width is not specified for all columns, and/or the height is not specified for all rows, then there is some ambiguity, and the result depends on the browser.  
'''Wiki markup'''
==== Wiki markup ====
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre><nowiki>
<blockquote style="border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre><nowiki>
{| style="width:75%; height:200px" border="1"
{| style="width:75%; height:200px" border="1"
|-  
|-  
Line 248: Line 247:
|}
|}
</nowiki></pre></blockquote>
</nowiki></pre></blockquote>
'''What it looks like in your browser'''
==== What it looks like in your browser ====
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;">
<blockquote style="border: 1px solid rgb(153, 153, 153); padding: 1em;">
{| style="width:75%; height:200px" border="1"
{| style="width:75%; height:200px" border="1"
|-  
|-  
Line 268: Line 267:
====Setting your column widths====
====Setting your column widths====
If you wish to force column widths to your own requirements, rather than accepting the width of the widest text element in a column's cells, then follow this example.  Note that wrap-around of text is forced.
If you wish to force column widths to your own requirements, rather than accepting the width of the widest text element in a column's cells, then follow this example.  Note that wrap-around of text is forced.
<blockquote style="background: white; border: 1px solid black; padding: 1em;"><pre><nowiki>
<blockquote style="border: 1px solid black; padding: 1em;"><pre><nowiki>
{| border="1" cellpadding="2"
{| border="1" cellpadding="2"
!width="50"|Name
!width="50"|Name
Line 283: Line 282:
|}
|}
</nowiki></pre></blockquote>
</nowiki></pre></blockquote>
<blockquote style="background: white; border: 1px solid black; padding: 1em;">
<blockquote style="border: 1px solid black; padding: 1em;">
{| border="1" cellpadding="2"
{| border="1" cellpadding="2"
!width="50"|Name
!width="50"|Name
Line 299: Line 298:
</blockquote>
</blockquote>
===Positioning===
===Positioning===
One can position the table itself, and all contents in a row, and contents in a cell, but not with a single parameter all contents in the table, see [[m:Template talk:Table demo]]. Do not, under any circumstances, use "float" to position a table. It will break page rendering at large font sizes.
One can position the table itself, and all contents in a row, and contents in a cell, but not with a single parameter all contents in the table. Do not, under any circumstances, use "float" to position a table. It will break page rendering at large font sizes.
 
===M&eacute;lange===
===M&eacute;lange===
Here's a more advanced example, showing some more options available for making up tables. 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 -- remember, other people are going to be editing the article too! This example should give you an idea of what is possible, though.
Here's a more advanced example, showing some more options available for making up tables. 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 -- remember, other people are going to be editing the article too! This example should give you an idea of what is possible, though.
'''Wiki markup'''
==== Wiki markup ====
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre><nowiki>
<blockquote style="border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre><nowiki>
{| border="1" cellpadding="5" cellspacing="0" align="center"
{| border="1" cellpadding="5" cellspacing="0" align="center"
|+'''An example table'''
|+'''An example table'''
Line 327: Line 327:
| align="center" colspan="2" style="border-top:1px solid red; border-right:1px
| align="center" colspan="2" style="border-top:1px solid red; border-right:1px
           solid red; border-bottom:2px solid red; border-left:1px solid red;" |
           solid red; border-bottom:2px solid red; border-left:1px solid red;" |
Two Wikipedia logos
Two Halopedia logos
|}
|}
|}
|}
</nowiki></pre></blockquote>
</nowiki></pre></blockquote>
'''What it looks like in your browser'''
==== What it looks like in your browser ====
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;">
<blockquote style="border: 1px solid rgb(153, 153, 153); padding: 1em;">
{| border="1" cellpadding="1" cellspacing="0" align="center"
{| border="1" cellpadding="1" cellspacing="0" align="center"
|+'''An example table'''
|+'''An example table'''
Line 355: Line 355:
|-
|-
| align="center" colspan="2" style="border-top:1px solid red; border-right:1px solid red; border-bottom:2px solid red; border-left:1px solid red;" |
| align="center" colspan="2" style="border-top:1px solid red; border-right:1px solid red; border-bottom:2px solid red; border-left:1px solid red;" |
Two Wikipedia logos
Two Halopedia logos
|}
|}
|}
|}
Line 361: Line 361:


=== Floating table ===
=== Floating table ===
'''Wiki markup'''
==== Wiki markup ====
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre><nowiki>
<blockquote style="border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre><nowiki>
This paragraph is before the table.  Lorem ipsum ...
This paragraph is before the table.  Lorem ipsum ...
{| align="right" border="1"
{| align="right" border="1"
Line 374: Line 374:
Note the floating table to the right.  This paragraph is after the table.  Lorem ipsum ...
Note the floating table to the right.  This paragraph is after the table.  Lorem ipsum ...
</nowiki></pre></blockquote>
</nowiki></pre></blockquote>
'''What it looks like in your browser'''
==== What it looks like in your browser ====
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;">
<blockquote style="border: 1px solid rgb(153, 153, 153); padding: 1em;">
This paragraph is before the table.  Lorem ipsum ...
This paragraph is before the table.  Lorem ipsum ...
{| align="right" border="1"
{| align="right" border="1"
Line 390: Line 390:
=== Nested tables ===
=== Nested tables ===
This shows one table (in blue) nested inside another table's cell2.  ''Nested tables have to start on a new line.''
This shows one table (in blue) nested inside another table's cell2.  ''Nested tables have to start on a new line.''
'''Wiki markup'''
==== Wiki markup ====
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre><nowiki>
<blockquote style="border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre><nowiki>
{| border="1"
{| border="1"
| &amp;alpha;
| &amp;alpha;
Line 403: Line 403:
|}
|}
</nowiki></pre></blockquote>
</nowiki></pre></blockquote>
'''What it looks like in your browser'''
==== What it looks like in your browser ====
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;">
<blockquote style="border: 1px solid rgb(153, 153, 153); padding: 1em;">
{| border="1"
{| border="1"
| &alpha;
| &alpha;
Line 418: Line 418:


===Combined use of COLSPAN and ROWSPAN===
===Combined use of COLSPAN and ROWSPAN===
'''Wiki markup'''
==== Wiki markup ====
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre><nowiki>
<blockquote style="border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre><nowiki>
{| border="1" cellpadding="5" cellspacing="0"
{| border="1" cellpadding="5" cellspacing="0"
|-
|-
Line 443: Line 443:
|}
|}
</nowiki></pre></blockquote>
</nowiki></pre></blockquote>
'''What it looks like in your browser'''
==== What it looks like in your browser ====
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;">
<blockquote style="border: 1px solid rgb(153, 153, 153); padding: 1em;">
{| border="1" cellpadding="5" cellspacing="0"
{| border="1" cellpadding="5" cellspacing="0"
|-
|-
Line 472: Line 472:
Centered tables can be achieved, but they will not "float"; that is to say, no text will appear to either side. The trick is <tt><nowiki>{| style="margin: 1em auto 1em auto"</nowiki></tt>
Centered tables can be achieved, but they will not "float"; that is to say, no text will appear to either side. The trick is <tt><nowiki>{| style="margin: 1em auto 1em auto"</nowiki></tt>


'''Wiki markup'''
==== Wiki markup ====
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre><nowiki>
<blockquote style="border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre><nowiki>
{| class="wikitable" style="margin: 1em auto 1em auto"
{| class="wikitable" style="margin: 1em auto 1em auto"
|+ '''Cells left-aligned, table centered'''
|+ '''Cells left-aligned, table centered'''
Line 483: Line 483:
|}
|}
</nowiki></pre></blockquote>
</nowiki></pre></blockquote>
'''What it looks like in your browser'''
==== What it looks like in your browser ====
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;">
<blockquote style="border: 1px solid rgb(153, 153, 153); padding: 1em;">
{| class="wikitable" style="margin: 1em auto 1em auto"
{| class="wikitable" style="margin: 1em auto 1em auto"
|+ '''Cells left-aligned, table centered'''
|+ '''Cells left-aligned, table centered'''
Line 498: Line 498:
At the start of a cell, add your parameter followed by a single pipe. For example <tt>width=300px|</tt> will set that cell to a width of 300 pixels. To set more than one parameter, leave a space between each one.
At the start of a cell, add your parameter followed by a single pipe. For example <tt>width=300px|</tt> will set that cell to a width of 300 pixels. To set more than one parameter, leave a space between each one.
=== Wiki markup ===
=== Wiki markup ===
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre><nowiki>
<blockquote style="border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre><nowiki>
{| style="color:white"
{| style="color:white"
|-
|-
Line 505: Line 505:
</nowiki></pre></blockquote>
</nowiki></pre></blockquote>
=== What it looks like in your browser ===
=== What it looks like in your browser ===
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;">
<blockquote style="border: 1px solid rgb(153, 153, 153); padding: 1em;">
{| style="color:white"
{| style="color:white"
|-
|-
Line 514: Line 514:
==Decimal point alignment==
==Decimal point alignment==
A method to get columns of numbers aligned at the decimal point is as follows:
A method to get columns of numbers aligned at the decimal point is as follows:
'''Wiki markup'''
==== Wiki markup ====
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre><nowiki>
<blockquote style="border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre><nowiki>
{| cellpadding="0" cellspacing="0"
{| cellpadding="0" cellspacing="0"
|align="right"| 432 || .1
|align="right"| 432 || .1
Line 524: Line 524:
|}
|}
</nowiki></pre></blockquote>
</nowiki></pre></blockquote>
'''What it looks like in your browser'''
==== What it looks like in your browser ====
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;">
<blockquote style="border: 1px solid rgb(153, 153, 153); padding: 1em;">
{| cellpadding="0" cellspacing="0"
{| cellpadding="0" cellspacing="0"
|align="right"| 432 || .1
|align="right"| 432 || .1
Line 535: Line 535:
</blockquote>
</blockquote>
If the column of numbers appears in a table with cell padding or cell spacing, one can still align the decimal points without an unsightly gap in the middle.  Embed a table in each number's cell and specify its column widths.  Make the embedded tables' column widths the same for each cell in the column.  (If decimal points are still misaligned using this method, the main table's column may be too narrow.  Add a parameter to increase the column's width.)
If the column of numbers appears in a table with cell padding or cell spacing, one can still align the decimal points without an unsightly gap in the middle.  Embed a table in each number's cell and specify its column widths.  Make the embedded tables' column widths the same for each cell in the column.  (If decimal points are still misaligned using this method, the main table's column may be too narrow.  Add a parameter to increase the column's width.)
'''Wiki markup'''
==== Wiki markup ====
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre><nowiki>
<blockquote style="border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre><nowiki>
{|border="1" cellpadding="4" cellspacing="2" width="72"
{|border="1" cellpadding="4" cellspacing="2" width="72"
|
|
Line 554: Line 554:
|}
|}
</nowiki></pre></blockquote>
</nowiki></pre></blockquote>
'''What it looks like in your browser'''
==== What it looks like in your browser ====
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;">
<blockquote style="border: 1px solid rgb(153, 153, 153); padding: 1em;">
{|border="1" cellpadding="4" cellspacing="2" width="72"
{|border="1" cellpadding="4" cellspacing="2" width="72"
|
|
Line 580: Line 580:
Some users have created [[w:CSS|CSS]] classes and [[Help:templates|templates]] to make table styles easier.  Instead of remembering table parameters, you just include an appropriate style class after the <code>{|</code>.  This helps keep table formatting consistent, and can allow a single change to the class to fix a problem or enhance the look of all the tables that are using it at once.  For instance, this:
Some users have created [[w:CSS|CSS]] classes and [[Help:templates|templates]] to make table styles easier.  Instead of remembering table parameters, you just include an appropriate style class after the <code>{|</code>.  This helps keep table formatting consistent, and can allow a single change to the class to fix a problem or enhance the look of all the tables that are using it at once.  For instance, this:
<table border="0" align="center"><tr><td width="46%">
<table border="0" align="center"><tr><td width="46%">
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre><nowiki>
<blockquote style="border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre><nowiki>
{| border="1" cellpadding="2"
{| border="1" cellpadding="2"
|+Multiplication table
|+Multiplication table
Line 603: Line 603:
</nowiki></pre></blockquote>
</nowiki></pre></blockquote>
</td><td>&#160;</td><td width="48%">
</td><td>&#160;</td><td width="48%">
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;">
<blockquote style="border: 1px solid rgb(153, 153, 153); padding: 1em;">
{| border="1" cellpadding="2"
{| border="1" cellpadding="2"
|+Multiplication table
|+Multiplication table
Line 627: Line 627:
<td colspan="3" align="center">becomes this:</td></tr>
<td colspan="3" align="center">becomes this:</td></tr>
<tr><td width="46%">
<tr><td width="46%">
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre><nowiki>
<blockquote style="border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre><nowiki>
{| class="wikitable"
{| class="wikitable"
|+Multiplication table
|+Multiplication table
Line 650: Line 650:
</nowiki></pre></blockquote>
</nowiki></pre></blockquote>
</td><td>&#160;</td><td width="48%">
</td><td>&#160;</td><td width="48%">
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;">
<blockquote style="border: 1px solid rgb(153, 153, 153); padding: 1em;">
{| class="wikitable"
{| class="wikitable"
|+Multiplication table
|+Multiplication table
Line 672: Line 672:
|}
|}
</blockquote></td></tr></table>
</blockquote></td></tr></table>
simply by replacing the parameters of the table (<code>border="1" cellpadding="2"</code> or the like) with <code><nowiki>class="wikitable"</nowiki></code>  This is because the ''wikitable'' class in [[Wikipedia:MediaWiki:Common.css|MediaWiki:Common.css]] contains a number of ''table.wikitable'' [[w:CSS|CSS]] style rules.  These are all applied at once when you mark a table with the class.  You can then add additional style rules if desired.  These override the class's rules, allowing you to use the class style as a base and build up on it:
simply by replacing the parameters of the table (<code>border="1" cellpadding="2"</code> or the like) with <code><nowiki>class="wikitable"</nowiki></code>  This is because the ''wikitable'' class in [[wikipedia:MediaWiki:Common.css|MediaWiki:Common.css]] contains a number of ''table.wikitable'' [[w:CSS|CSS]] style rules.  These are all applied at once when you mark a table with the class.  You can then add additional style rules if desired.  These override the class's rules, allowing you to use the class style as a base and build up on it:
'''Wiki markup'''
==== Wiki markup ====
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre><nowiki>
<blockquote style="border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre><nowiki>
{| class="wikitable" style="font-style:italic; font-size:120%; border:3px dashed red;"
{| class="wikitable" style="font-style:italic; font-size:120%; border:3px dashed red;"
|+Multiplication table
|+Multiplication table
Line 696: Line 696:
|}
|}
</nowiki></pre></blockquote>
</nowiki></pre></blockquote>
'''What it looks like in your browser'''
==== What it looks like in your browser ====
<blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;">
<blockquote style="border: 1px solid rgb(153, 153, 153); padding: 1em;">
{| class="wikitable" style="font-style:italic; font-size:120%; border:3px dashed red;"
{| class="wikitable" style="font-style:italic; font-size:120%; border:3px dashed red;"
|+Multiplication table
|+Multiplication table
Line 721: Line 721:
Notice that the table retains the gray background of the wikitable class, and the headers are still bold and centered.  But now the text formatting has been overridden by the local ''style'' statement; all of the text in the table has been made italic and 120% normal size, and the wikitable border has been replaced by the red dashed border.
Notice that the table retains the gray background of the wikitable class, and the headers are still bold and centered.  But now the text formatting has been overridden by the local ''style'' statement; all of the text in the table has been made italic and 120% normal size, and the wikitable border has been replaced by the red dashed border.


 
{{Halopedia HAGP}}
[[Category: Help|Tables]]
[[Category:Help]]

Latest revision as of 14:13, March 18, 2022

Introduction

In Halopedia you can create a table by using the HTML code. However, Halopedia offers a simpler way to create a table. If you have a table in HTML that you want to convert to a wiki-table please refer to the Wiki-Table generators.

Pipe syntax tutorial

The Wiki table using the | or pipe sign as a way to create a table. Below is an example and explanation of how to create a table.

  • The entire table is encased with curly brackets and a vertical bar character (a pipe). So use {| to begin a table, and |} to end it. Each one needs to be on its own line:
{|
  table code goes here
|}
  • An optional table caption is included with a line starting with a vertical bar and plus sign "|+" and the caption after it:
{|
|+ caption
  table code goes here
|}
  • To start a new table row, type a vertical bar and a dash on its own line: "|-". The codes for the cells in that row will start on the next line.
{|
|+ The table's caption
|-
  cell code goes here
|-
  cell code goes here
|}
  • Type the codes for each table cell in the next row, starting with a bar:
{|
|+ The table's caption
|-
| cell codes go here
|-
| cells in the next row go here
| more cells in the same row here
|}
  • Cells can be separated with either a new line and new bar, or by a double bar "||" on the same line. Both produce the same output:
{|
|+ The table's caption
|-
|Cell 1 || Cell 2 || Cell 3
|-
|Cell A 
|Cell B
|Cell C
|}
  • a row of column headings is identified by using "!" instead of "|", and using "!!" instead of "||". Header cells typically render differently than regular cells, depending on the browser. They are often rendered in a bold font and centered.
{|
|+ The table's caption
! Column heading 1 !! Column heading 2 !! Column heading 3
|-
|Cell 1 || Cell 2 || Cell 3
|-
|Cell A
|Cell B
|Cell C
|}
  • the first cell of a row is identified as row heading by starting the line with "!" instead of "|", and starting subsequent data cells on a new line.
{|
|+ The table's caption
! Column heading 1 !! Column heading 2 !! Column heading 3
|-
! Row heading 1 
| Cell 2 || Cell 3
|-
! Row heading A 
|Cell B
|Cell C
|}
  • Optional parameters can modify the behavior of cells, rows, or the entire table. For instance, a border could be added to the table:
{| border="1"
|+ The table's caption
! Column heading 1 !! Column heading 2 !! Column heading 3
|-
! Row heading 1
| Cell 2 || Cell 3
|-
! Row heading A
|Cell B ||Cell C
|}

The final table would display like this:

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

The table parameters and cell parameters are the same as in HTML, see [1] and HTML element#Tables.

A table can be useful even if none of the cells have content. For example, the background colors of cells can be changed with cell parameters, making the table into a diagram. An "image" in the form of a table is much more convenient to edit than an uploaded image.

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, see colspan and rowspan in Mélange example below). For empty cells, use the non-breaking space &nbsp; as content to ensure that the cells are displayed. To show a visible pipe in a cell, use <nowiki>|</nowiki> or &#124;.

Examples

Simple example

Both of these generate the same output. Choose a style based on the amount of cells in each row and the total text inside each cell.

Wiki markup

{| 
| Cell 1, row 1 
| Cell 2, row 1 
|- 
| Cell 1, row 2 
| Cell 2, row 2 
|}
{| 
| Cell 1, row 1 || Cell 2, row 1 
|- 
| Cell 1, row 2 || Cell 2, row 2 
|}

What it looks like in your browser

Cell 1, row 1 Cell 2, row 1
Cell 1, row 2 Cell 2, row 2

Multiplication table

Wiki markup

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

What it looks like in your browser

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

Color; scope of parameters

Two ways of specifying color of text and background for a single cell are as follows. The first form is preferred:

Wiki markup

{| 
| style="background:red; color:white" | abc
| def
| bgcolor="red" | <font color="white"> ghi </font>
| jkl
|}

What it looks like in your browser

abc def ghi jkl

Like other parameters, colors can also be specified for a whole row or the whole table; parameters for a row override the value for the table, and those for a cell override those for a row:

Wiki markup

{| style="background:yellow; color:green"
|- 
| abc
| def
| ghi
|- style="background:red; color:white"
| jkl
| mno
| pqr
|-
| stu
| style="background:silver" | vwx
| yz
|}

What it looks like in your browser

abc def ghi
jkl mno pqr
stu vwx yz

To make the table blend in with the background, use style="background:none". (Warning: style="background:inherit", does not work with some browsers, including IE6!)

Width, height

The width and height of the whole table can be specified, as well as the height of a row. To specify the width of a column one can specify the width of an arbitrary cell in it. If the width is not specified for all columns, and/or the height is not specified for all rows, then there is some ambiguity, and the result depends on the browser.

Wiki markup

{| style="width:75%; height:200px" border="1"
|- 
| abc
| def
| ghi
|- style="height:100px" 
| jkl
| style="width:200px" |mno
| pqr
|-
| stu
| vwx
| yz
|}

What it looks like in your browser

abc def ghi
jkl mno pqr
stu vwx yz

Note that style="inline CSS" has no effect with some browsers. If it's important equivalent older constructs like width="75%" should work on more browsers.

Setting your column widths

If you wish to force column widths to your own requirements, rather than accepting the width of the widest text element in a column's cells, then follow this example. Note that wrap-around of text is forced.

{| border="1" cellpadding="2"
!width="50"|Name
!width="225"|Effect
!width="225"|Games Found In
|-
|Pokeball
|Regular Pokeball
|All Versions
|-
|Great Ball
|Better than a Pokeball
|All Versions
|}
Name Effect Games Found In
Pokeball Regular Pokeball All Versions
Great Ball Better than a Pokeball All Versions

Positioning

One can position the table itself, and all contents in a row, and contents in a cell, but not with a single parameter all contents in the table. Do not, under any circumstances, use "float" to position a table. It will break page rendering at large font sizes.

Mélange

Here's a more advanced example, showing some more options available for making up tables. 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 -- remember, other people are going to be editing the article too! This example should give you an idea of what is possible, though.

Wiki markup

{| border="1" cellpadding="5" cellspacing="0" align="center"
|+'''An example table'''
|-
! style="background:#efefef;" | First header
! colspan="2" style="background:#ffdead;" | Second header
|-
| upper left
|  
| rowspan=2 style="border-bottom:3px solid grey;" valign="top" |
right side
|-
| style="border-bottom:3px solid grey;" | lower left
| style="border-bottom:3px solid grey;" | lower middle
|-
| colspan="3" align="center" |
{| border="0"
|+''A table in a table''
|-
| align="center" width="150px" | [[Image:wiki.png]]
| align="center" width="150px" | [[Image:wiki.png]]
|-
| align="center" colspan="2" style="border-top:1px solid red; border-right:1px
          solid red; border-bottom:2px solid red; border-left:1px solid red;" |
Two Halopedia logos
|}
|}

What it looks like in your browser

An example table
First header Second header
upper left  

right side

lower left lower middle
A table in a table
Wiki.png Wiki.png

Two Halopedia logos

Floating table

Wiki markup

This paragraph is before the table.  Lorem ipsum ...
{| align="right" border="1"
| Col 1, row 1 
|rowspan="2"| Col 2, row 1 (and 2) 
| Col 3, row 1 
|- 
| Col 1, row 2 
| Col 3, row 2 
|}
Note the floating table to the right.   This paragraph is after the table.  Lorem ipsum ...

What it looks like in your browser

This paragraph is before the table. Lorem ipsum ...

Col 1, row 1 Col 2, row 1 (and 2) Col 3, row 1
Col 1, row 2 Col 3, row 2

Note the floating table to the right. This paragraph is after the table. Lorem ipsum ...

Nested tables

This shows one table (in blue) nested inside another table's cell2. Nested tables have to start on a new line.

Wiki markup

{| border="1"
| &alpha;
| align="center" | cell2
{| border="2" style="background-color:#ABCDEF;"
| NESTED
|-
| TABLE
|}
| valign="top" | the original table again
|}

What it looks like in your browser

α cell2
NESTED
TABLE
the original table again

Combined use of COLSPAN and ROWSPAN

Wiki markup

{| border="1" cellpadding="5" cellspacing="0"
|-
! Column 1 || Column 2 || Column 3
|-
| rowspan="2"| A
| colspan="2" align="center"| B
|-
| C
| D
|-
| E
| colspan="2" align="center"| F
|- 
| rowspan="3"| G
| H
| I
|- 
| J
| K
|-
| colspan="2" align="center"| L
|}

What it looks like in your browser

Column 1 Column 2 Column 3
A B
C D
E F
G H I
J K
L

Centering tables

Centered tables can be achieved, but they will not "float"; that is to say, no text will appear to either side. The trick is {| style="margin: 1em auto 1em auto"

Wiki markup

{| class="wikitable" style="margin: 1em auto 1em auto"
|+ '''Cells left-aligned, table centered'''
! Duis || aute || irure
|-
| dolor  || in reprehenderit || in voluptate velit
|-
| esse cillum dolore || eu fugiat nulla || pariatur.
|}

What it looks like in your browser

Cells left-aligned, table centered
Duis aute irure
dolor in reprehenderit in voluptate velit
esse cillum dolore eu fugiat nulla pariatur.

Setting parameters

At the start of a cell, add your parameter followed by a single pipe. For example width=300px| will set that cell to a width of 300 pixels. To set more than one parameter, leave a space between each one.

Wiki markup

{| style="color:white"
|-
| bgcolor="red"|cell1 || width="300" bgcolor="blue"|cell2 || bgcolor="green"|cell3
|}

What it looks like in your browser

cell1 cell2 cell3

Decimal point alignment

A method to get columns of numbers aligned at the decimal point is as follows:

Wiki markup

{| cellpadding="0" cellspacing="0"
|align="right"| 432 || .1
|-
|align="right"| 43 || .21
|-
|align="right"| 4 || .321
|}

What it looks like in your browser

432 .1
43 .21
4 .321

If the column of numbers appears in a table with cell padding or cell spacing, one can still align the decimal points without an unsightly gap in the middle. Embed a table in each number's cell and specify its column widths. Make the embedded tables' column widths the same for each cell in the column. (If decimal points are still misaligned using this method, the main table's column may be too narrow. Add a parameter to increase the column's width.)

Wiki markup

{|border="1" cellpadding="4" cellspacing="2" width="72"
|
{|cellpadding="0" cellspacing="0" width="100%"
|align="right" width="50%"| 432 ||width="50%"| .1
|}
|-
|
{|cellpadding="0" cellspacing="0" width="100%"
|align="right" width="50%"| 43 ||width="50%"| .21
|}
|-
|
{|cellpadding="0" cellspacing="0" width="100%"
|align="right" width="50%"| 4 ||width="50%"| .321
|}
|}

What it looks like in your browser

432 .1
43 .21
4 .321

In simple cases one can dispense with the table feature and simply start the lines with a space, and put spaces to position the numbers:

432.1
 43.21
  4.321

Style classes

Some users have created CSS classes and templates to make table styles easier. Instead of remembering table parameters, you just include an appropriate style class after the {|. This helps keep table formatting consistent, and can allow a single change to the class to fix a problem or enhance the look of all the tables that are using it at once. For instance, this:

{| border="1" cellpadding="2"
|+Multiplication table
|-
! &times; !! 1 !! 2 !! 3
|-
! 1
| 1 || 2 || 3
|-
! 2
| 2 || 4 || 6
|-
! 3
| 3 || 6 || 9
|-
! 4
| 4 || 8 || 12
|-
! 5
| 5 || 10 || 15
|}
 
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
becomes this:
{| class="wikitable"
|+Multiplication table
|-
! &times; !! 1 !! 2 !! 3
|-
! 1
| 1 || 2 || 3
|-
! 2
| 2 || 4 || 6
|-
! 3
| 3 || 6 || 9
|-
! 4
| 4 || 8 || 12
|-
! 5
| 5 || 10 || 15
|}
 
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

simply by replacing the parameters of the table (border="1" cellpadding="2" or the like) with class="wikitable" This is because the wikitable class in MediaWiki:Common.css contains a number of table.wikitable CSS style rules. These are all applied at once when you mark a table with the class. You can then add additional style rules if desired. These override the class's rules, allowing you to use the class style as a base and build up on it:

Wiki markup

{| class="wikitable" style="font-style:italic; font-size:120%; border:3px dashed red;"
|+Multiplication table
|-
! &times; !! 1 !! 2 !! 3
|-
! 1
| 1 || 2 || 3
|-
! 2
| 2 || 4 || 6
|-
! 3
| 3 || 6 || 9
|-
! 4
| 4 || 8 || 12
|-
! 5
| 5 || 10 || 15
|}

What it looks like in your browser

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

Notice that the table retains the gray background of the wikitable class, and the headers are still bold and centered. But now the text formatting has been overridden by the local style statement; all of the text in the table has been made italic and 120% normal size, and the wikitable border has been replaced by the red dashed border.