Help:Tables: Difference between revisions

no edit summary
m (Protected "Help:Tables" ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)))
No edit summary
Line 1: Line 1:
== 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-table 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 75:
  <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 100: Line 98:
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 107:
|}
|}
</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 117: 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 128: Line 126:
===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 151: 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 176: Line 174:
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 185: 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 195: Line 193:
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 212: 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 232: Line 230:
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 249: 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 266:
====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 281:
|}
|}
</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 304: Line 302:
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 333: Line 331:
</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 363: 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 376: Line 374:
</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 392: Line 390:
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 405: 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 420: 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 445: 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 474: Line 472:


==== 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 485: 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 499: Line 497:
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 506: Line 504:
</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 516: Line 514:
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 526: 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 537: Line 535:
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 556: 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 581: Line 579:
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 604: Line 602:
</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 628: Line 626:
<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 651: Line 649:
</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 675: Line 673:
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 698: 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 722: Line 720:
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.


==See also==
{{Halopedia HAGP}}
{{Halopedia HAGP}}
 
[[Category:Help]]
[[Category: Help|Tables]]