|
|
(15 intermediate revisions by 3 users not shown) |
Line 1: |
Line 1: |
− | {{for|basic use of a wikitable|Help:Wikitable}}
| + | == Upcoming Meetings == |
− | {{Wiki markup}}
| + | *[https://hallaweb.jlab.org/doc-private/DisplayMeeting?conferenceid=11 Spring 2017 Collaboration Meeting] |
| + | **Bluejeans information: |
| + | To join the Meeting: |
| + | https://bluejeans.com/541975048 |
| + | To join via Browser: |
| + | https://bluejeans.com/541975048/browser |
| + | To join with Lync: |
| + | https://bluejeans.com/541975048/lync |
| + | To join via Cisco Jabber Video: |
| + | https://bluejeans.com/541975048/jabber <br/> |
| + | To join via Room System: |
| + | Video Conferencing System: bjn.vc -or-199.48.152.152 |
| + | Meeting ID : 541975048 <br/> |
| + | To join via phone : |
| + | 1) Dial: |
| + | +1.408.740.7256 |
| + | +1.888.240.2560 |
| + | +1.408.317.9253 |
| + | (see all numbers - http://bluejeans.com/numbers) |
| + | 2) Enter Conference ID : 541975048 |
| | | |
− | A '''wikitable''' is an arrangement of columns and rows used to organize and position data. Tables are useful, and there are many ways and tricks that can be used. This page gives you information about syntax to build wikitables in Wikipedia.
| + | == Previous Meetings == |
| + | *[https://hallaweb.jlab.org/doc-private/DisplayMeeting?conferenceid=13 Winter 2018 Collaboration Meeting] |
| + | *[https://hallaweb.jlab.org/doc-private/DisplayMeeting?conferenceid=11 Spring 2017 Collaboration Meeting] |
| + | *[https://hallaweb.jlab.org/doc-private/DisplayMeeting?conferenceid=10 Fall 2016 Collaboration Meeting] |
| + | *[https://hallaweb.jlab.org/doc-private/DisplayMeeting?conferenceid=5 Fall 2013 Collaboration Meeting] |
| + | *[https://hallaweb.jlab.org/doc-private/DisplayMeeting?conferenceid=4 Summer 2013 Collaboration Meeting] |
| + | *[https://hallaweb.jlab.org/doc-private/DisplayMeeting?conferenceid=3 Fall 2012 Collaboration Meeting] |
| + | *[https://hallaweb.jlab.org/doc-private/DisplayMeeting?conferenceid=2 December 2010 Collaboration Meeting] |
| | | |
− | == Using the toolbar ==
| + | <br><br> Return to [[MOLLER at 11 GeV E09-005]] |
− | | + | |
− | [[File:Toolbar2.PNG|center]]
| + | |
− | To automatically insert a table, click [[File:Button insert table.png]] (Insert a table) on the [[Help:Edit toolbar|edit toolbar]]. If "Insert a table" is not on the toolbar follow [[mw:Customizing edit toolbar|these directions]] to add it.
| + | |
− | | + | |
− | The following text is inserted when '''Insert a table''' is clicked:
| + | |
− | <pre style="display: inline-block;">
| + | |
− | {| 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
| + | |
− | |}
| + | |
− | </pre>
| + | |
− | {| 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
| + | |
− | |-
| + | |
− | | row 3,cell 1|| row 3, cell 2|| row 3, cell 3
| + | |
− | |}
| + | |
− | The sample text ("header 1" or "row 1, cell 1") is to be replaced with actual data.</div>
| + | |
− | | + | |
− | == Pipe syntax tutorial ==
| + | |
− | | + | |
− | {| border="3" style="margin-left: 3em;"
| + | |
− | |-
| + | |
− | ! scope="col" | Column heading 1
| + | |
− | ! scope="col" | Column heading 2
| + | |
− | ! scope="col" | Column heading 3
| + | |
− | |-
| + | |
− | ! scope="row" | Row heading 1
| + | |
− | | Cell 2
| + | |
− | | Cell 3
| + | |
− | |-
| + | |
− | ! scope="row" | Row heading A
| + | |
− | | Cell B
| + | |
− | | Cell C
| + | |
− | |}
| + | |
− | | + | |
− | Although HTML table syntax also works, special [[wikicode]] can be used as a shortcut to create a table. The pipe ([[w:vertical bar|vertical bar]]) codes function exactly the same as [[w:HTML table|HTML table]] markup, so a knowledge of HTML table code will help in understanding pipe code. The shortcuts are as follows:
| + | |
− | * The entire table is encased with curly brackets and a 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:
| + | |
− | <span style="color: #a63;">'''<nowiki>{|</nowiki>'''</span>
| + | |
− | ''table code goes here''
| + | |
− | <span style="color: #a63;">'''<nowiki>|}</nowiki>'''</span>
| + | |
− | * An optional '''table caption''' is included with a line starting with a vertical bar and plus sign "<code>'''|+'''</code>" and the caption after it:
| + | |
− | <nowiki>{|</nowiki>
| + | |
− | <span style="color: #a63;">'''<nowiki>|+</nowiki> ''caption'''''</span>
| + | |
− | ''table code goes here''
| + | |
− | <nowiki>|}</nowiki>
| + | |
− | * To start a new '''table [[row]]''', type a vertical bar and a [[w:hyphen|hyphen]] on its own line: "<code>'''|-'''</code>". The codes for the cells in that row will start on the next line.
| + | |
− | <nowiki>{|</nowiki>
| + | |
− | <nowiki>|+</nowiki> The table's caption
| + | |
− | <span style="color: #a63;">'''<nowiki>|-</nowiki>'''</span>
| + | |
− | ''row code goes here''
| + | |
− | <span style="color: #a63;">'''<nowiki>|-</nowiki>'''</span>
| + | |
− | ''row code goes here''
| + | |
− | <nowiki>|}</nowiki>
| + | |
− | * Type the codes for each ''table [[w:cell|cell]]'' in the next row, starting with a bar:
| + | |
− | <nowiki>{|</nowiki>
| + | |
− | <nowiki>|+</nowiki> The table's caption
| + | |
− | <nowiki>|-</nowiki>
| + | |
− | <span style="color: #a63;">'''|'''</span> ''cell codes go here''
| + | |
− | <nowiki>|-</nowiki>
| + | |
− | <span style="color: #a63;">'''|'''</span> ''cells in the next row go here''
| + | |
− | <span style="color: #a63;">'''|'''</span> ''more cells in the same row here''
| + | |
− | <nowiki>|}</nowiki>
| + | |
− | * 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:
| + | |
− | <nowiki>{|</nowiki>
| + | |
− | <nowiki>|+</nowiki> The table's caption
| + | |
− | <nowiki>|-</nowiki>
| + | |
− | <span style="color: #a63;">'''|Cell 1 || Cell 2 || Cell 3'''</span>
| + | |
− | <nowiki>|-</nowiki>
| + | |
− | <span style="color: #a63;">'''|Cell A'''</span>
| + | |
− | <span style="color: #a63;">'''|Cell B'''</span>
| + | |
− | <span style="color: #a63;">'''|Cell C'''</span>
| + | |
− | <nowiki>|}</nowiki>
| + | |
− | * If you use single bars, then what might appear to be the first cell is in fact a format modifier applied to the cell, and the rest of your "cells" will be merged into one:
| + | |
− | <nowiki>{| border="1"</nowiki>
| + | |
− | <nowiki>|-</nowiki>
| + | |
− | <nowiki>|format modifier (not displayed)</nowiki> <span style="color: #a63;">'''|'''</span><nowiki>These all </nowiki> <span style="color: #a63;">'''|'''</span><nowiki>(including the pipes)</nowiki> <span style="color: #a63;">'''|'''</span><nowiki>go into </nowiki> <span style="color: #a63;">'''|'''</span><nowiki>the first cell</nowiki>
| + | |
− | <nowiki>|}</nowiki>
| + | |
− | which is probably not what you want:
| + | |
− | {| border="1"
| + | |
− | |-
| + | |
− | | format modifier (not displayed)|These all |(including the pipes)|go into |the first cell
| + | |
− | |}
| + | |
− | However, the format modifier is useful:
| + | |
− | <nowiki>{| border="1"</nowiki>
| + | |
− | <nowiki>|-</nowiki>
| + | |
− | <nowiki>| Cell 1 (no modifier — not aligned)</nowiki>
| + | |
− | <nowiki>|-</nowiki>
| + | |
− | <nowiki>| align="right" | Cell 2 (right aligned)</nowiki>
| + | |
− | <nowiki>|}</nowiki>
| + | |
− | | + | |
− | {| border="1"
| + | |
− | |-
| + | |
− | | Cell 1 (no modifier — not aligned)
| + | |
− | |-
| + | |
− | | style="text-align: right;" | Cell 2 (right aligned)
| + | |
− | |}
| + | |
− | | + | |
− | Just remember: no more than 2 single pipes on a line!
| + | |
− | | + | |
− | * a row of '''column headings''' is identified by using "! scope="col" |" instead of "|", and using "!! scope="col" |" instead of "||". Header cells typically render differently from regular cells, depending on the browser. They are often rendered in a bold font and centered.
| + | |
− | <nowiki>{|</nowiki>
| + | |
− | <nowiki>|+</nowiki> The table's caption
| + | |
− | <span style="color: #a63;">'''! scope="col" | Column heading 1'''
| + | |
− | '''! scope="col" | Column heading 2'''
| + | |
− | '''! scope="col" | Column heading 3'''</span>
| + | |
− | <nowiki>|-</nowiki>
| + | |
− | | Cell 1 || Cell 2 || Cell 3
| + | |
− | <nowiki>|-</nowiki>
| + | |
− | | Cell A
| + | |
− | | Cell B
| + | |
− | | Cell C
| + | |
− | <nowiki>|}</nowiki>
| + | |
− | * the first cell of a row is identified as a '''row heading''' by starting the line with "! scope="row" |" instead of "|", and starting subsequent data cells on a new line.
| + | |
− | <nowiki>{|</nowiki>
| + | |
− | <nowiki>|+</nowiki> The table's caption
| + | |
− | ! scope="col" | Column heading 1
| + | |
− | ! scope="col" | Column heading 2
| + | |
− | ! scope="col" | Column heading 3
| + | |
− | <nowiki>|-</nowiki>
| + | |
− | <span style="color: #a63;">'''! scope="row" | Row heading 1'''</span>
| + | |
− | | Cell 2 || Cell 3
| + | |
− | <nowiki>|-</nowiki>
| + | |
− | <span style="color: #a63;">'''! scope="row" | Row heading A'''</span>
| + | |
− | | Cell B
| + | |
− | | Cell C
| + | |
− | <nowiki>|}</nowiki>
| + | |
− | * Optional '''parameters''' can modify the behavior of cells, rows, or the entire table. For instance, a border could be added to the table:
| + | |
− | <nowiki>{|</nowiki> <span style="color: #a63;">'''border="1"'''</span>
| + | |
− | <nowiki>|+</nowiki> The table's caption
| + | |
− | ! scope="col" | Column heading 1
| + | |
− | ! scope="col" | Column heading 2
| + | |
− | ! scope="col" | Column heading 3
| + | |
− | <nowiki>|-</nowiki>
| + | |
− | ! scope="row" | Row heading 1
| + | |
− | | Cell 2 || Cell 3
| + | |
− | <nowiki>|-</nowiki>
| + | |
− | ! scope="row" | Row heading A
| + | |
− | | Cell B
| + | |
− | | Cell C
| + | |
− | <nowiki>|}</nowiki>
| + | |
− | The final table would display like this:
| + | |
− | <div style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;">
| + | |
− | {| border="1"
| + | |
− | |+ The table's caption
| + | |
− | ! scope="col" | Column heading 1
| + | |
− | ! scope="col" | Column heading 2
| + | |
− | ! scope="col" | Column heading 3
| + | |
− | |-
| + | |
− | ! scope="row" | Row heading 1
| + | |
− | | Cell 2 || Cell 3
| + | |
− | |-
| + | |
− | ! scope="row" | Row heading A
| + | |
− | | Cell B
| + | |
− | | Cell C
| + | |
− | |}
| + | |
− | </div>
| + | |
− | The table parameters and cell parameters are the same as in [[w:HTML|HTML]], see http://www.w3.org/TR/html401/struct/tables.html#edef-TABLE and [[w:Table (HTML)|Table (HTML)]]. However, the <code>thead</code>, <code>tbody</code>, <code>tfoot</code>, <code>colgroup</code>, and <code>col</code> elements are currently not [[Help:HTML in wikitext#Permitted HTML|supported in MediaWiki]].
| + | |
− | | + | |
− | 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 [[meta:Template talk:Square 8x8 pentomino example]]. 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. For empty cells, use the non-breaking space <code>&nbsp;</code> as content to ensure that the cells are displayed. To show a visible pipe in a cell, use <tt><nowiki>|</nowiki></tt> or <tt>&#124;</tt>.
| + | |
− | | + | |
− | With colspan and rowspan cells can span several columns or rows, see the [[Help:Table#Mélange|Mélange]] example below. However, this has the disadvantage that [[help:sorting|sorting]] does not work properly anymore.
| + | |
− | | + | |
− | == Examples ==
| + | |
− | | + | |
− | === Simple example ===
| + | |
− | Both of these generate the same output. Choose a style based on the number of cells in each row and the total text inside each cell.
| + | |
− | | + | |
− | The wiki markup code:
| + | |
− | <pre>
| + | |
− | <nowiki>
| + | |
− | {|
| + | |
− | | A
| + | |
− | | B
| + | |
− | |-
| + | |
− | | C
| + | |
− | | D
| + | |
− | |}
| + | |
− | </nowiki></pre>
| + | |
− | | + | |
− | <pre>
| + | |
− | <nowiki>
| + | |
− | {|
| + | |
− | | A || B
| + | |
− | |-
| + | |
− | | C || D
| + | |
− | |}
| + | |
− | </nowiki></pre>
| + | |
− | | + | |
− | What it looks like in your browser:
| + | |
− | <div style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;">
| + | |
− | {|
| + | |
− | |-
| + | |
− | | A
| + | |
− | | B
| + | |
− | |-
| + | |
− | | C
| + | |
− | | D
| + | |
− | |}
| + | |
− | </div>
| + | |
− | | + | |
− | === Multiplication table ===
| + | |
− | | + | |
− | Here is the wiki markup code:
| + | |
− | <pre style="overflow: auto;">
| + | |
− | {| class="wikitable" style="text-align: center; width: 200px; height: 200px;"
| + | |
− | |+ Multiplication table
| + | |
− | |-
| + | |
− | ! scope="col" | ×
| + | |
− | ! scope="col" | 1
| + | |
− | ! scope="col" | 2
| + | |
− | ! scope="col" | 3
| + | |
− | |-
| + | |
− | ! scope="row" | 1
| + | |
− | | 1 || 2 || 3
| + | |
− | |-
| + | |
− | ! scope="row" | 2
| + | |
− | | 2 || 4 || 6
| + | |
− | |-
| + | |
− | ! scope="row" | 3
| + | |
− | | 3 || 6 || 9
| + | |
− | |-
| + | |
− | ! scope="row" | 4
| + | |
− | | 4 || 8 || 12
| + | |
− | |-
| + | |
− | ! scope="row" | 5
| + | |
− | | 5 || 10 || 15
| + | |
− | |}
| + | |
− | </pre>
| + | |
− | | + | |
− | and what it looks like in your browser (see ''[[Help:User style]]''):
| + | |
− | | + | |
− | <div style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;">
| + | |
− | {| class="wikitable" style="text-align: center; width: 200px; height: 200px;"
| + | |
− | |+ Multiplication table
| + | |
− | |-
| + | |
− | ! scope="col" | ×
| + | |
− | ! scope="col" | 1
| + | |
− | ! scope="col" | 2
| + | |
− | ! scope="col" | 3
| + | |
− | |-
| + | |
− | ! scope="row" | 1
| + | |
− | | 1 || 2 || 3
| + | |
− | |-
| + | |
− | ! scope="row" | 2
| + | |
− | | 2 || 4 || 6
| + | |
− | |-
| + | |
− | ! scope="row" | 3
| + | |
− | | 3 || 6 || 9
| + | |
− | |-
| + | |
− | ! scope="row" | 4
| + | |
− | | 4 || 8 || 12
| + | |
− | |-
| + | |
− | ! scope="row" | 5
| + | |
− | | 5 || 10 || 15
| + | |
− | |}
| + | |
− | </div>
| + | |
− | | + | |
− | === Color; scope of parameters ===
| + | |
− | | + | |
− | Two ways of specifying [[Wikipedia:Colours|color]] of text and background for a single cell are as follows. The first form is preferred because the second form uses deprecated HTML:
| + | |
− | | + | |
− | The wiki markup code:
| + | |
− | <pre style="display: inline-block;">
| + | |
− | <nowiki>
| + | |
− | {|
| + | |
− | | style="background: red; color: white" | abc
| + | |
− | | def
| + | |
− | | bgcolor="red" | <font color="white"> ghi </font>
| + | |
− | | jkl
| + | |
− | |}
| + | |
− | </nowiki></pre>
| + | |
− | | + | |
− | What it looks like in your browser:
| + | |
− | <div style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;">
| + | |
− | {|
| + | |
− | |-
| + | |
− | | style="background: red; color: white" | abc
| + | |
− | | def
| + | |
− | | style="background: red;"| <span style="color: white;"> ghi </span>
| + | |
− | | jkl
| + | |
− | |}
| + | |
− | </div>
| + | |
− | | + | |
− | 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. (Note that there is no easy way to specify a color for a whole column—each cell in the column must be individually specified. Tools can make it easier.):
| + | |
− | | + | |
− | The wiki markup code:
| + | |
− | <pre style="display: inline-block;">
| + | |
− | <nowiki>
| + | |
− | {| style="background: yellow; color: green"
| + | |
− | |-
| + | |
− | | abc || def || ghi
| + | |
− | |- style="background: red; color: white"
| + | |
− | | jkl || mno || pqr
| + | |
− | |-
| + | |
− | | stu || style="background: silver" | vwx || yz
| + | |
− | |}
| + | |
− | </nowiki></pre>
| + | |
− | | + | |
− | What it looks like in your browser:
| + | |
− | <div style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;">
| + | |
− | {| style="background: yellow; color: green"
| + | |
− | |-
| + | |
− | | abc || def || ghi
| + | |
− | |- style="background: red; color: white"
| + | |
− | | jkl || mno || pqr
| + | |
− | |-
| + | |
− | | stu || style="background: silver" | vwx || yz
| + | |
− | |}
| + | |
− | </div>
| + | |
− | | + | |
− | To make the table blend in with the background, use <code>style="background: none;"</code> or <code>style="background: transparent;"</code>. (Warning: <code>style="background: inherit;"</code>, does not work with some browsers, including IE6!)
| + | |
− | | + | |
− | To force a cell to match one of the default colors of the [[Help:User style|<code>class="wikitable"</code> template]], use <code>style="background: #f2f2f2"</code> for the darker header, and <code>style="background: #f9f9f9"</code> for the lighter body.
| + | |
− | | + | |
− | See : [[w:style| style]], [[w:background|background]], [[w:list of colors|list of colors]], [[w:web colors|web colors]]
| + | |
− | | + | |
− | === 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 wiki markup code:
| + | |
− | <pre style="display: inline-block;">
| + | |
− | <nowiki>
| + | |
− | {| style="width: 75%; height: 200px" border="1"
| + | |
− | |-
| + | |
− | | abc || def || ghi
| + | |
− | |- style="height: 100px;"
| + | |
− | | jkl || style="width: 200px;" | mno || pqr
| + | |
− | |-
| + | |
− | | stu || vwx || yz
| + | |
− | |}
| + | |
− | </nowiki>
| + | |
− | </pre>
| + | |
− | | + | |
− | What it looks like in your browser:
| + | |
− | <div style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;">
| + | |
− | {| style="width:75%; height:200px" border="1"
| + | |
− | |-
| + | |
− | | abc || def || ghi
| + | |
− | |- style="height: 100px;"
| + | |
− | | jkl || style="width: 200px;" | mno || pqr
| + | |
− | |-
| + | |
− | | stu || vwx || yz
| + | |
− | |}
| + | |
− | </div>
| + | |
− | | + | |
− | Note that <code>style="</code>inline CSS<code>"</code> has no effect with some browsers. If compatibility is important, equivalent older constructs like <code>width="75%"</code> should work on more browsers.
| + | |
− | | + | |
− | ==== Setting column widths ====
| + | |
− | To force column widths to specific requirements, rather than accepting the width of the widest text element in a column's cells, follow this example. Note that [[word wrap|wrap-around of text]] is forced.
| + | |
− | | + | |
− | The wiki markup code:
| + | |
− | <pre style="display: inline-block;">
| + | |
− | <nowiki>
| + | |
− | {| border="1" cellpadding="2"
| + | |
− | ! scope="col" width="50" | Name
| + | |
− | ! scope="col" width="225" | Effect
| + | |
− | ! scope="col" width="225" | Games Found In
| + | |
− | |-
| + | |
− | | Poké Ball || Regular Poké Ball || All Versions
| + | |
− | |-
| + | |
− | | Great Ball || Better than a Poké Ball || All Versions
| + | |
− | |}
| + | |
− | </nowiki>
| + | |
− | </pre>
| + | |
− | | + | |
− | <div style="background: white; border: 1px solid black; padding: 1em;">
| + | |
− | {| border="1" cellpadding="2"
| + | |
− | |-
| + | |
− | ! scope="col" width="50" | Name
| + | |
− | ! scope="col" style="width: 225px;" | Effect
| + | |
− | ! scope="col" style="width: 225px;" | Games Found In
| + | |
− | |-
| + | |
− | |Poké Ball || Regular Poké Ball || All Versions
| + | |
− | |-
| + | |
− | |Great Ball || Better than a Poké Ball || All Versions
| + | |
− | |}
| + | |
− | </div>
| + | |
− | | + | |
− | To set column widths in a table without headers, specify the width in the first cell for each column, like this:
| + | |
− | | + | |
− | <pre style="display: inline-block;">
| + | |
− | <nowiki>
| + | |
− | {| border="1" cellpadding="2"
| + | |
− | |-
| + | |
− | | width="100pt" | This column is 100 points wide
| + | |
− | | width="200pt" | This column is 200 points wide
| + | |
− | | width="300pt" | This column is 300 points wide
| + | |
− | |-
| + | |
− | | blah || blih || bluh
| + | |
− | |}
| + | |
− | </nowiki>
| + | |
− | </pre>
| + | |
− | | + | |
− | <div style="background: white; border: 1px solid black; padding: 1em;">
| + | |
− | {| border="1" cellpadding="2"
| + | |
− | |-
| + | |
− | | style="width: 100pt;" | This column is 100 points wide
| + | |
− | | style="width: 200pt;" | This column is 200 points wide
| + | |
− | | style="width: 300pt;" | This column is 300 points wide
| + | |
− | |-
| + | |
− | | blah || blih || bluh
| + | |
− | |}
| + | |
− | </div>
| + | |
− | | + | |
− | One application of setting the widths is aligning columns of consecutive tables:
| + | |
− | | + | |
− | {| border="1" cellpadding="2"
| + | |
− | |-
| + | |
− | ! scope="col" style="width: 350px;" | Country
| + | |
− | ! scope="col" style="width: 225px;" | Capital
| + | |
− | |-
| + | |
− | | The Netherlands || Amsterdam
| + | |
− | |}
| + | |
− | | + | |
− | {| border="1" cellpadding="2"
| + | |
− | |-
| + | |
− | ! scope="col" style="width: 350px;" | Country
| + | |
− | ! scope="col" style="width: 225px;" | Capital
| + | |
− | |-
| + | |
− | | France || Paris
| + | |
− | |}
| + | |
− | | + | |
− | | + | |
− | =====Nowrap=====
| + | |
− | In a table that spans the entire width of a page, cells narrower than the widest cell tend to wrap. To keep an entire column from wrapping, use <tt>style=white-space:nowrap</tt> in a non-header cell on the longest/widest cell to affect the entire column.
| + | |
− | | + | |
− | Before:
| + | |
− | {|"class=wikitable sortable"
| + | |
− | |-
| + | |
− | ! scope="col" | Episode
| + | |
− | ! scope="col" | Date
| + | |
− | ! scope="col" | Summary
| + | |
− | |-
| + | |
− | |"The Journey Begins"
| + | |
− | |January 1, 2010
| + | |
− | |[[Lorem ipsum]] dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
| + | |
− | |-
| + | |
− | |"When Episodes Attack"
| + | |
− | |January 8, 2010
| + | |
− | |Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
| + | |
− | |-
| + | |
− | |"So Long"
| + | |
− | |January 15, 2010
| + | |
− | |Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
| + | |
− | |}
| + | |
− | | + | |
− | After:
| + | |
− | {|"class=wikitable sortable"
| + | |
− | |-
| + | |
− | ! scope="col" | Episode
| + | |
− | ! scope="col" | Date
| + | |
− | ! scope="col" | Summary
| + | |
− | |-
| + | |
− | |"The Journey Begins"
| + | |
− | |January 1, 2010
| + | |
− | |Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
| + | |
− | |-
| + | |
− | |style=white-space:nowrap|"When Episodes Attack"
| + | |
− | |January 8, 2010
| + | |
− | |Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
| + | |
− | |-
| + | |
− | |"So Long"
| + | |
− | |style=white-space:nowrap|January 15, 2010
| + | |
− | |Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
| + | |
− | |}
| + | |
− | | + | |
− | === Setting borders ===
| + | |
− | Table borders default to a complex shaded double-line (the default in HTML); however, those borders can be set to a thin solid line by using a style-parameter (style="border: 1px solid darkgray"), as in the following (''Note: if you intend to use the 'cellpadding' or 'cellspacing' options along with a border, you MUST use this format''):
| + | |
− | | + | |
− | <pre style="display: inline-block;">
| + | |
− | <nowiki>
| + | |
− | {| cellpadding="2" style="border: 1px solid darkgray;"
| + | |
− | ! width="140" | Left
| + | |
− | ! width="150" | Middle
| + | |
− | ! width="130" | Right
| + | |
− | |- border="0"
| + | |
− | | [[File:StarIconBronze.png|120px]]
| + | |
− | | [[File:StarIconGold.png|120px|Caption when mouse-over image]]
| + | |
− | | [[File:StarIconGreen.png|120px|Green stellar icon]]
| + | |
− | |- align="center"
| + | |
− | | Bronze star || Gold star || Green star
| + | |
− | |}
| + | |
− | </nowiki>
| + | |
− | </pre>
| + | |
− | Note the bottom-row texts are centered by 'align="center"' while star-images were not centered.
| + | |
− | | + | |
− | {| cellpadding="2" style="border: 1px solid darkgrey; margin-left: 4em;"
| + | |
− | |-
| + | |
− | ! style="width: 140px;" | Left
| + | |
− | ! style="width: 150px;" | Middle
| + | |
− | ! style="width: 130px;" | Right
| + | |
− | |- border="0"
| + | |
− | | [[File:StarIconBronze.png|120px]]
| + | |
− | | [[File:StarIconGold.png|120px|Caption when mouse-over image]]
| + | |
− | | [[File:StarIconGreen.png|120px|Green stellar icon]]
| + | |
− | |- align="center"
| + | |
− | | Bronze star || Gold star || Green star
| + | |
− | |}
| + | |
− | | + | |
− | As long as the "Image:" specs omit the parameter "thumb|" they will not show the caption lines in the table (only during mouse-over). The border color "darkgray" matches typical tables or infoboxes in articles; however, it could be any color name (such as style="border: 1px solid darkgreen;") or use a hex-color (such as: #DDCCBB).
| + | |
− | | + | |
− | A column format-specifier (enclosed in "|...|") can have a style-parameter to set borders on each cell, as follows:
| + | |
− | | + | |
− | <pre style="display: inline-block;">
| + | |
− | <nowiki>
| + | |
− | {| cellpadding="2" style="border: 1px solid darkgray;"
| + | |
− | ! width="140" | Left
| + | |
− | ! width="150" | Middle
| + | |
− | ! width="130" | Right
| + | |
− | |- align="center"
| + | |
− | | style="border: 1px solid blue;"|
| + | |
− | [[File:StarIconBronze.png|120px]]
| + | |
− | | style="border: 1px solid #777777;"|
| + | |
− | [[File:StarIconGold.png|120px|Caption when mouse-over image]]
| + | |
− | | style="border: 1px solid #22AA55;"|<!--greenish border-->
| + | |
− | [[File:StarIconGreen.png|120px|Green stellar icon]]
| + | |
− | |- align="center"
| + | |
− | |Bronze star || Gold star || Green star
| + | |
− | |}
| + | |
− | </nowiki>
| + | |
− | </pre>
| + | |
− | | + | |
− | Note only the image cells, here, have individual borders, not the text.
| + | |
− | {| cellpadding="2" style="border: 1px solid darkgrey; margin-left:4em;"
| + | |
− | |-
| + | |
− | ! style="width:140px;"|Left || style="width:150px;"|Middle || style="width:130px;"|Right
| + | |
− | |- align="center"
| + | |
− | | style="border: 1px solid blue;"|
| + | |
− | [[File:StarIconBronze.png|120px]]
| + | |
− | | style="border: 1px solid #777;"|
| + | |
− | [[File:StarIconGold.png|120px|Caption when mouse-over image]]
| + | |
− | | style="border: 1px solid #2a5;"|<!--greenish border-->
| + | |
− | [[File:StarIconGreen.png|120px|Green stellar icon]]
| + | |
− | |- align="center"
| + | |
− | |Bronze star || Gold star || Green star
| + | |
− | |}
| + | |
− | The lower hex-colors (such as: #616161) are closer to black. Typically, all borders in a table would be one specific color.
| + | |
− | | + | |
− | === Vertical alignment ===
| + | |
− | By default data in tables is vertically centrally aligned, which results in odd-looking layouts like this:
| + | |
− | | + | |
− | {| border="1" cellpadding="2" style="width:400px; margin-left:6em;"
| + | |
− | |-
| + | |
− | ! scope="row" style="width:10%;"| Row heading
| + | |
− | | style="width:70%;"|A longer piece of text. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
| + | |
− | | style="width:20%;"|short text
| + | |
− | |-
| + | |
− | ! scope="row" | Row heading
| + | |
− | | Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.<br /><span style="color: #13a;">Imagine someone scrolling down the page, seeing the tops of "empty" columns, and wondering why they're empty. Use "'''valign=top'''" to align text at the top of columns.</span>
| + | |
− | | short text
| + | |
− | |}
| + | |
− | | + | |
− | To fix this, apply the valign="top" attribute to the rows (unfortunately it seems to be necessary to apply this individually to every single row). For example:
| + | |
− | <pre style="display: inline-block;">
| + | |
− | <nowiki>
| + | |
− | {| border="1" cellpadding="2" width="400"
| + | |
− | |- valign="top"
| + | |
− | ! scope="row" width="10%" | Row heading
| + | |
− | | width="70%" | A longer piece of text. Lorem ipsum...
| + | |
− | | width="20%" | short text
| + | |
− | |- valign="top"
| + | |
− | ! scope="row" | Row heading
| + | |
− | | Excepteur sint occaecat...
| + | |
− | | short text
| + | |
− | |}
| + | |
− | </nowiki>
| + | |
− | </pre>
| + | |
− | | + | |
− | {| border="1" cellpadding="2" style="width: 400px; margin-left: 6em;"
| + | |
− | |- valign="top"
| + | |
− | ! scope="row" style="width: 10%;" | Row heading
| + | |
− | | style="width: 70%;" | A longer piece of text. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
| + | |
− | | style="width: 20%;" | short text
| + | |
− | |- valign="top"
| + | |
− | ! scope="row" | Row heading
| + | |
− | | Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.<br /><span style="color: #14a;">Imagine someone scrolling down the page, seeing the tops of "empty" columns, and wondering why they're empty. Use "'''valign=top'''" to align text at the top of columns.</span>
| + | |
− | | short text
| + | |
− | |}
| + | |
− | | + | |
− | === Positioning ===
| + | |
− | You can position the table itself, the contents of a row, and the contents of a cell, but not with a single parameter for all the contents of the table. See [[m:Template talk:Table demo]]. Prior to April 2009, using "float" to position a table was discouraged; however, it no longer always breaks page rendering at large font sizes. See a floated image, below, under "[[#Floating images in the center|Floating images in the center]]".
| + | |
− | | + | |
− | === Mélange ===
| + | |
− | ''Note: This example is not [[Wikipedia:Manual of Style (accessibility)|accessible]], and should be avoided as much as possible. For example, nested tables (tables inside tables) should be separated into distinct tables when possible.''
| + | |
− | | + | |
− | Here's a more advanced example, showing some more options available for making up tables. Note however that with colspan and rowspan [[help:sorting|sorting]] does not work properly anymore.
| + | |
− | | + | |
− | 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.
| + | |
− | | + | |
− | The wiki markup code:
| + | |
− | <pre style="display: inline-block;">
| + | |
− | <nowiki>
| + | |
− | {| 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
| + | |
− | | &nbsp;
| + | |
− | | 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="150" | [[File:Wiki.png]]
| + | |
− | | align="center" width="150" | [[File: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 Wikipedia logos
| + | |
− | |}
| + | |
− | |}
| + | |
− | </nowiki>
| + | |
− | </pre>
| + | |
− | | + | |
− | What it looks like in your browser:
| + | |
− | <div style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;">
| + | |
− | {| border="1" cellpadding="1" cellspacing="0" style="margin: auto;"
| + | |
− | |+ '''An example table'''
| + | |
− | |-
| + | |
− | ! style="background: #efefef;" | First header
| + | |
− | ! colspan="2" style="background: #ffdead;" | Second header
| + | |
− | |-
| + | |
− | | upper left
| + | |
− | |
| + | |
− | | rowspan="2" style="border-bottom: 3px solid gray; vertical-align: top;"|
| + | |
− | right side
| + | |
− | |-
| + | |
− | | style="border-bottom: 3px solid gray;" | lower left
| + | |
− | | style="border-bottom: 3px solid gray;" | lower middle
| + | |
− | |-
| + | |
− | | colspan="3" style="text-align: center;" |
| + | |
− | {| border="0"
| + | |
− | |+ ''A table in a table''
| + | |
− | |- style="text-align: center;"
| + | |
− | || [[File:Wiki.png]]
| + | |
− | | style="width: 150px;" | [[File:Wiki.png]]
| + | |
− | |-
| + | |
− | | colspan="2" style="text-align: center; border-top: 1px solid red; <!--
| + | |
− | --> border-right: 1px solid red; border-bottom: 2px solid red; <!--
| + | |
− | --> border-left: 1px solid red;"|
| + | |
− | Two Wikipedia logos
| + | |
− | |}
| + | |
− | |}
| + | |
− | </div>
| + | |
− | | + | |
− | === Floating table ===
| + | |
− | The wiki markup coding:
| + | |
− | <pre style="display: inline-block;">
| + | |
− | <nowiki>
| + | |
− | This paragraph is before the table. Lorem ipsum dolor sit
| + | |
− | amet, consectetur adipisicing elit, sed do eiusmod...
| + | |
− | | + | |
− | {| style="float: 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. The text in column 2
| + | |
− | will span both rows due to format specifier "rowspan=2" so there
| + | |
− | is no coding for "Col 2" in the 2nd row, just: Col 1 & Col 3.
| + | |
− | </nowiki>
| + | |
− | </pre>
| + | |
− | | + | |
− | What it looks like in your browser:
| + | |
− | <div style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;">
| + | |
− | | + | |
− | This paragraph is before the table. Lorem ipsum dolor sit
| + | |
− | amet, consectetur adipisicing elit, sed do eiusmod...
| + | |
− | {| style="float: 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. The text in column 2
| + | |
− | will span both rows due to format specifier "rowspan=2" so there
| + | |
− | is no coding for "Col 2" in the 2nd row, just: Col 1 & Col 3.
| + | |
− | </div>
| + | |
− | | + | |
− | === Floating images in the center ===
| + | |
− | A table can be used to wrap an image, so that the table can float towards the center of the page (such as using: style="float: right;"). However, the table margins, border and font-size must be precisely set to match a typical image display. The Image-spec parameter "thumb|" (although auto-thumbnailing to user-preference width) forces a wide left-margin that squeezes the nearby text, so the parameter "center|" can be added to suppress the left-margin padding. However, "center" sometimes shoves the caption to a 2nd line (under a centered box "[]"), so "thumb|" could be omitted and just hard-code the image size, adding a gray (#BBB) border. Using precise parameters to match other images, a floating-image table can be coded as follows:
| + | |
− | <pre style="display: inline-block;">
| + | |
− | <nowiki>
| + | |
− | {| style="float: right; border: 1px solid #BBB; margin: .46em 0 0 .2em;"
| + | |
− | |- style="font-size: 86%;"
| + | |
− | | valign="top" |[[File:DuraEuropos-TempleOfBel.jpg|180px]]<!--
| + | |
− | --><br /> Temple of [[Bel (mythology)|Bel]] (floating).
| + | |
− | |}
| + | |
− | </nowiki>
| + | |
− | </pre>
| + | |
− | | + | |
− | The text inside the floating-table is sized by style="font-size: 86%;". That floating-image table floats a typical image-box, but allows adjusting the left-hand margin of the image (see temple-example floating below).
| + | |
− | {| class="infobox" style="width: 90px;"
| + | |
− | |-
| + | |
− | ! colspan="2" | Infobox A
| + | |
− | |-
| + | |
− | | colspan="2" | This sample infobox shows how the floating image-box aligns toward the center.
| + | |
− | |}
| + | |
− | {| style="float: right; border: 1px solid #BBB; margin: .46em 0 0 .2em;"
| + | |
− | |- style="font-size: 86%;"
| + | |
− | | valign="top" |[[File:DuraEuropos-TempleOfBel.jpg|180px]]<br /><!--
| + | |
− | --> Temple of [[Bel (mythology)|Bel]] (floating).
| + | |
− | |}
| + | |
− | {| style="float: right; clear:right; border: 1px solid black;"
| + | |
− | | valign="top" |[[File:DuraEuropos-TempleOfBel.jpg|thumb<!--
| + | |
− | -->|right|This table shows the implicit margins of <!--
| + | |
− | --> Images using "right".]]
| + | |
− | |}
| + | |
− | The caption-text can be omitted, or remove the parameter "thumb|" so the caption is hidden until "mouse-over display". Unfortunately the parameter "thumb|" (used for displaying the caption) also controls the auto-thumbnailing to re-size images by user-preferences size. In April 2009, it was not possible to have auto-thumbnail sizing while also concealing the caption: parameter "thumb|" triggers both actions and forces the caption to display.
| + | |
− | | + | |
− | An image set with parameter "left|" will gain a wide right-side margin (opposite margin of parameter "right|"), so floating toward the left would require an image set as "center|" inside a table with style="float:left; margin:0.46em 0.2em".
| + | |
− | | + | |
− | Recall that, outside an image-table, the parameter "right|" causes an image to align (either) above or below an infobox, but would not float alongside the infobox.
| + | |
− | | + | |
− | Note the ''order of precedence'': first come infoboxes or images using "right|", then come the floating-tables, and lastly, any text will wrap that can still fit. If the first text-word is too long, no text will fit to complete the left-hand side, so beware creating a "ragged left margin" when not enough space remains for text to fit alongside floating-tables.
| + | |
− | | + | |
− | If multiple single image-tables are stacked, they will float to align across the page, depending on page-width. The text will be squeezed to allow as many floating-tables as can fit, as auto-aligned, then wrap whatever text (can still fit) at the left-hand side.
| + | |
− | {| style="float: right; margin-left:0.2em; border: 1px solid #BBB;"
| + | |
− | |- style="font-size: 87%;"
| + | |
− | | valign="top" |[[File:DuraEuropos-TempleOfBel.jpg<!--
| + | |
− | -->|105px]]<br />...by float: right
| + | |
− | |}
| + | |
− | {| style="float: right; margin-left:0.2em; border: 1px solid #BBB;"
| + | |
− | |- style="font-size: 87%;"
| + | |
− | | valign="top" |[[File:DuraEuropos-TempleOfBel.jpg<!--
| + | |
− | -->|105px]]<br /> ...images wrap...
| + | |
− | |}
| + | |
− | {| style="float: right; margin-left:0.2em; border: 1px solid #BBB;"
| + | |
− | |- style="font-size: 87%;"
| + | |
− | | valign="top" |[[File:DuraEuropos-TempleOfBel.jpg<!--
| + | |
− | -->|105px]]<br />All these...
| + | |
− | |}
| + | |
− | | + | |
− | That auto-aligning feature can be used to create a "floating-gallery" of images: a set of 20 floating-tables will wrap (backward, right-to-left) as if each table were a word of text to wrap across and down the page. To wrap in the typical direction (wrapping left-to-right) define all those floating-tables, instead, as left-side tables using the top parameter style="float:left; margin:0.46em 0.2em". Multiple floating-images empower more flexible typesetting of images around the text.
| + | |
− | | + | |
− | === Nested tables ===
| + | |
− | ''Note: because they cause [[Wikipedia:Manual_of_Style_(accessibility)#Tables|accessibility issues]], nested tables should be avoided whenever possible.''
| + | |
− |
| + | |
− | Seven different (blue) tables are shown nested inside the cells of a table. Automatically the two tables |A| and |B|B| are vertically aligned instead of the usual side by side of text characters in a cell. "float" is used to fix each of tables |C| and |D| to their own position within one cell of the table. This may be used for charts and schemes. ''Nested tables must start on a new line.''
| + | |
− | | + | |
− | '''Wiki markup'''
| + | |
− | <!-- <div style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;">-->
| + | |
− | <p style="border: 1px dashed #2f6fab; background: #f9f9f9;"><tt>
| + | |
− | <nowiki>{|</nowiki> border="1"<br />
| + | |
− | | &alpha;<br />
| + | |
− | | style="text-align: center;"| cell2<br />
| + | |
− | <span style="color: navy;">
| + | |
− | '''<nowiki>{|</nowiki> border="2" style="background: #ABCDEF;"''' <nowiki><!--</nowiki> '''The nested table must be on a new line''' <nowiki>--></nowiki><br />
| + | |
− | '''| NESTED'''<br />
| + | |
− | '''|-'''<br />
| + | |
− | '''| TABLE'''<br />
| + | |
− | '''<nowiki>|}</nowiki>'''<br />
| + | |
− | </span>
| + | |
− | | style="vertical-align:bottom;"| the original table again<br />
| + | |
− | | style="width:100px;" |<br />
| + | |
− | <span style="color: navy;">
| + | |
− | '''<nowiki>{|</nowiki> border="2" style="background: #ABCDEF;"'''<br />
| + | |
− | '''| A'''<br />
| + | |
− | '''<nowiki>|}</nowiki>'''<br />
| + | |
− | '''<nowiki>{|</nowiki> border="2" style="background: #ABCDEF;"'''<br />
| + | |
− | '''| B || B'''<br />
| + | |
− | '''<nowiki>|}</nowiki>'''<br />
| + | |
− | </span>
| + | |
− | | style="width:50px;" |<br />
| + | |
− | <span style="color: navy;">
| + | |
− | '''<nowiki>{|</nowiki> border="2" style="background: #ABCDEF; float:left;"'''<br />
| + | |
− | '''| C'''<br />
| + | |
− | '''<nowiki>|}</nowiki>'''<br />
| + | |
− | '''<nowiki>{|</nowiki> border="2" style="background: #ABCDEF; float: right;"'''<br />
| + | |
− | '''| D'''<br />
| + | |
− | '''<nowiki>|}</nowiki>'''<br />
| + | |
− | </span>
| + | |
− | <nowiki>|}</nowiki>
| + | |
− | </tt></p><!--</div>-->
| + | |
− | | + | |
− | '''What it looks like in your browser'''
| + | |
− | {| border="1"
| + | |
− | |-
| + | |
− | | α
| + | |
− | | style="text-align: center;"| cell2
| + | |
− | {| border="2" style="background: #ABCDEF;"
| + | |
− | |-
| + | |
− | | NESTED
| + | |
− | |-
| + | |
− | | TABLE
| + | |
− | |}
| + | |
− | | style="vertical-align: bottom;" | the original table again
| + | |
− | | style="width: 100px;" |
| + | |
− | {| border="2" style="background: #ABCDEF;"
| + | |
− | |-
| + | |
− | | A
| + | |
− | |}
| + | |
− | {| border="2" style="background: #ABCDEF;"
| + | |
− | |-
| + | |
− | | B || B
| + | |
− | |}
| + | |
− | | style="width: 50px;" |
| + | |
− | {| border="2" style="background: #ABCDEF; float:left;"
| + | |
− | |-
| + | |
− | | C
| + | |
− | |}
| + | |
− | {| border="2" style="background: #ABCDEF; float: right;"
| + | |
− | |-
| + | |
− | | D
| + | |
− | |}
| + | |
− | |}
| + | |
− | | + | |
− | === Combined use of COLSPAN and ROWSPAN ===
| + | |
− | | + | |
− | '''Wiki markup'''
| + | |
− | <pre style="display: inline-block;">
| + | |
− | <nowiki>
| + | |
− | {| border="1" cellpadding="5" cellspacing="0"
| + | |
− | |-
| + | |
− | | Column 1 || Column 2 || Column 3
| + | |
− | |-
| + | |
− | | rowspan="2" | A
| + | |
− | | colspan="2" style="text-align: center;" | B
| + | |
− | |-
| + | |
− | | C <!-- column 1 occupied by cell A -->
| + | |
− | | D
| + | |
− | |-
| + | |
− | | E
| + | |
− | | rowspan="2" colspan="2" style="text-align: center;" | F
| + | |
− | |-
| + | |
− | | G <!-- column 2+3 occupied by cell F -->
| + | |
− | |-
| + | |
− | | colspan="3" style="text-align: center;" | H
| + | |
− | |}
| + | |
− | </nowiki>
| + | |
− | </pre>
| + | |
− | | + | |
− | '''What it looks like in your browser'''
| + | |
− | {| border="1" cellpadding="5" cellspacing="0"
| + | |
− | |-
| + | |
− | | Column 1 || Column 2 || Column 3
| + | |
− | |-
| + | |
− | | rowspan="2" | A
| + | |
− | | colspan="2" style="text-align: center;" | B
| + | |
− | |-
| + | |
− | | C <!-- column 1 occupied by cell A -->
| + | |
− | | D
| + | |
− | |-
| + | |
− | | E
| + | |
− | | rowspan="2" colspan="2" style="text-align: center;" | F
| + | |
− | |-
| + | |
− | | G <!-- column 2+3 occupied by cell F -->
| + | |
− | |-
| + | |
− | | colspan="3" style="text-align: center;" | H
| + | |
− | |}
| + | |
− | | + | |
− | Note that using <code>rowspan="2"</code> for cell '''G''' combined with <code>rowspan="3"</code> for cell '''F''' to get another row below '''G''' and '''F''' won't work, because all (implicit) cells would be empty.
| + | |
− | Likewise complete columns are not displayed if all their cells are empty. Borders between non-empty and empty cells might be also not displayed (depending on the browser), use <code>&nbsp;</code> to fill an empty cell with dummy content.
| + | |
− | | + | |
− | === 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 <tt><nowiki>{| style="margin: 1em auto 1em auto;"</nowiki></tt>
| + | |
− | | + | |
− | '''Wiki markup'''
| + | |
− | <pre style="display: inline-block;">
| + | |
− | <nowiki>
| + | |
− | {| class="wikitable" style="margin: 1em auto 1em auto;"
| + | |
− | |+ '''Cells left-aligned, table centered'''
| + | |
− | ! scope="col" | Duis
| + | |
− | ! scope="col" | aute
| + | |
− | ! scope="col" | irure
| + | |
− | |-
| + | |
− | | dolor || in reprehenderit || in voluptate velit
| + | |
− | |-
| + | |
− | | esse cillum dolore || eu fugiat nulla || pariatur.
| + | |
− | |}
| + | |
− | </nowiki>
| + | |
− | </pre>
| + | |
− | | + | |
− | '''What it looks like in your browser'''
| + | |
− | {| 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.
| + | |
− | |}
| + | |
− | | + | |
− | === Setting parameters ===
| + | |
− | At the start of a cell, add your parameter followed by a single pipe. For example <tt>width="300"|</tt> will set that cell to a width of 300 pixels. To set more than one parameter, leave a space between each one, as follows:
| + | |
− | | + | |
− | <pre style="display: inline-block;">
| + | |
− | <nowiki>
| + | |
− | {| style="color:white"
| + | |
− | |-
| + | |
− | | bgcolor="red"|cell1 || width="300" bgcolor="blue"|cell2
| + | |
− | | bgcolor="green"|cell3
| + | |
− | |}
| + | |
− | </nowiki>
| + | |
− | </pre>
| + | |
− | | + | |
− | What it looks like in your browser:
| + | |
− | {| style="color:white"
| + | |
− | |-
| + | |
− | | style="background:red;"|cell1 || style="width:300px; background:blue;"|cell2 || style="background:green;"|cell3
| + | |
− | |}
| + | |
− | | + | |
− | === Tiny tables within a text line ===
| + | |
− | For years in [[HTML]], a table has always forced an implicit line-wrap (or ''line-break''), so to keep a table within a line, the work-around is to put all text into a table, then embed a table-within-a-table, using the outer table to force the whole line to stay together. Consider the following examples:
| + | |
− | | + | |
− | : Wikicode (''showing table forces line-break''):
| + | |
− | :: <nowiki>* This is a test table here <table style="border: 1px solid black"><tr><td>HELLO WORLD</table> followed by this text afterward.</nowiki>
| + | |
− | :Result:
| + | |
− | ::* This is a test table here <table style="border: 1px solid black"><tr><td>HELLO WORLD</table> followed by this text afterward.
| + | |
− | : Wikicode (''table-within-table''):
| + | |
− | :: <nowiki>* <table style="background-color: #fafeff"><tr><td>This is a test table here<td><table height=11px><tr><td style="border: 1px solid black; font-size:60%">HELLO WORLD</table></td><td>followed by this text afterward.</table> This line is more text after the outer table.</nowiki>
| + | |
− | :Result:
| + | |
− | ::* <table style="background: #fafeff;"><tr><td>This is a test table here<td><table style="height:11px;"><tr><td style="border: 1px solid black; font-size:60%">HELLO WORLD</table></td><td>followed by this text afterward.</table> This line is more text after the outer table.
| + | |
− | Use style="font-size:60%" to shrink the text within the box. However, the small text could be replaced with small images (aligned inside the inner table). The outer table is for one line only, so to make a 2nd line appear even, the exact length of line 1 must be pre-determined, to match the length of other lines.
| + | |
− | | + | |
− | === Decimal point alignment ===
| + | |
− | A method to get columns of numbers aligned at the decimal point is as follows:
| + | |
− | <pre style="display: inline-block;">
| + | |
− | <nowiki>
| + | |
− | {| cellpadding="0" cellspacing="0"
| + | |
− | | align="right" | 432 || .1
| + | |
− | |-
| + | |
− | | align="right" | 43 || .21
| + | |
− | |-
| + | |
− | | align="right" | 4 || .321
| + | |
− | |}
| + | |
− | </nowiki>
| + | |
− | </pre>
| + | |
− | | + | |
− | What it looks like in your browser:
| + | |
− | <div style="background:white; border: 1px solid darkgrey;">
| + | |
− | {| cellpadding="0" cellspacing="0"
| + | |
− | |-
| + | |
− | | align="right" | 432 || .1
| + | |
− | |-
| + | |
− | | align="right" | 43 || .21
| + | |
− | |-
| + | |
− | | align="right" | 4 || .321
| + | |
− | |}
| + | |
− | </div>
| + | |
− | | + | |
− | If the column of numbers appears in a table with cell padding or cell spacing, you 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.)
| + | |
− | The wiki markup code:
| + | |
− | <pre style="display: inline-block;">
| + | |
− | <nowiki>
| + | |
− | {| border="1" cellpadding="4" cellspacing="2"
| + | |
− | |
| + | |
− | {| 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
| + | |
− | |}
| + | |
− | |}
| + | |
− | </nowiki>
| + | |
− | </pre>
| + | |
− | | + | |
− | What it looks like in your browser:
| + | |
− | <div style="background:white; border: 1px solid darkgrey;">
| + | |
− | {| border="1" cellpadding="4" cellspacing="2"
| + | |
− | |
| + | |
− | {| cellpadding="0" cellspacing="0" style="width: 100px;"
| + | |
− | |-
| + | |
− | | style="text-align: right; width: 50%;" | 432 || style="width: 50%;" | .1
| + | |
− | |}
| + | |
− | |-
| + | |
− | |
| + | |
− | {| cellpadding="0" cellspacing="0" style="width:100px;"
| + | |
− | |-
| + | |
− | | style="text-align: right; width: 50%;" | 43 || style="width: 50%;" | .21
| + | |
− | |}
| + | |
− | |-
| + | |
− | |
| + | |
− | {| cellpadding="0" cellspacing="0" style="width:100px;"
| + | |
− | |-
| + | |
− | | style="text-align: right; width: 50%;" | 4 || style="width: 50%;" | .321
| + | |
− | |}
| + | |
− | |}
| + | |
− | </div>
| + | |
− | | + | |
− | In simple cases you 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 ==
| + | |
− | | + | |
− | : ''See also [[Help:User style]].''
| + | |
− | | + | |
− | In the first line of table code, after the "{|", instead of specifying a style directly, you can also specify a [[w:Cascading Style Sheets|CSS]] class. The style for this class can be specified in various ways:
| + | |
− | * in the software itself, per skin (for example the class sortable)
| + | |
− | * collectively for all users of one wiki in [[MediaWiki:Common.css]] (for example, on this and some other projects there is or was the class wikitable, later moved to [http://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/skins/common/shared.css?view=markup shared.css])
| + | |
− | * separately per skin in [[MediaWiki:Monobook.css]] etc.
| + | |
− | * individually on one wiki in a user subpage
| + | |
− | * individually, but jointly for tables of the class concerned on all web pages, on the local computer of the user.
| + | |
− | | + | |
− | 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" style="margin: auto;"><tr><td style="width:46%;">
| + | |
− | <div style="background:white; border:0 solid rgb(153, 153, 153); padding:1em;"><pre><nowiki>
| + | |
− | {| cellpadding="2"
| + | |
− | |+ Multiplication table
| + | |
− | |-
| + | |
− | ! scope="col" | &times;
| + | |
− | ! scope="col" | 1
| + | |
− | ! scope="col" | 2
| + | |
− | ! scope="col" | 3
| + | |
− | |-
| + | |
− | ! scope="row" | 1
| + | |
− | | 1 || 2 || 3
| + | |
− | |-
| + | |
− | ! scope="row" | 2
| + | |
− | | 2 || 4 || 6
| + | |
− | |-
| + | |
− | ! scope="row" | 3
| + | |
− | | 3 || 6 || 9
| + | |
− | |-
| + | |
− | ! scope="row" | 4
| + | |
− | | 4 || 8 || 12
| + | |
− | |-
| + | |
− | ! scope="row" | 5
| + | |
− | | 5 || 10 || 15
| + | |
− | |}
| + | |
− | </nowiki></pre></div>
| + | |
− | </td><td> </td><td style="width:48%;">
| + | |
− | <div style="background:white; border:0 solid rgb(153, 153, 153); padding:1em;">
| + | |
− | {| cellpadding="2"
| + | |
− | |+ Multiplication table
| + | |
− | |-
| + | |
− | ! scope="col" | ×
| + | |
− | ! scope="col" | 1
| + | |
− | ! scope="col" | 2
| + | |
− | ! scope="col" | 3
| + | |
− | |-
| + | |
− | ! scope="row" | 1
| + | |
− | | 1 || 2 || 3
| + | |
− | |-
| + | |
− | ! scope="row" | 2
| + | |
− | | 2 || 4 || 6
| + | |
− | |-
| + | |
− | ! scope="row" | 3
| + | |
− | | 3 || 6 || 9
| + | |
− | |-
| + | |
− | ! scope="row" | 4
| + | |
− | | 4 || 8 || 12
| + | |
− | |-
| + | |
− | ! scope="row" | 5
| + | |
− | | 5 || 10 || 15
| + | |
− | |}
| + | |
− | </div></td></tr><tr>
| + | |
− | <td colspan="3" style="text-align: center;">becomes this:</td></tr>
| + | |
− | <tr><td style="width:46%;">
| + | |
− | <div style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;"><pre><nowiki>
| + | |
− | {| class="wikitable"
| + | |
− | |+ Multiplication table
| + | |
− | |-
| + | |
− | ! scope="col" | &times;
| + | |
− | ! scope="col" | 1
| + | |
− | ! scope="col" | 2
| + | |
− | ! scope="col" | 3
| + | |
− | |-
| + | |
− | ! scope="row" | 1
| + | |
− | | 1 || 2 || 3
| + | |
− | |-
| + | |
− | ! scope="row" | 2
| + | |
− | | 2 || 4 || 6
| + | |
− | |-
| + | |
− | ! scope="row" | 3
| + | |
− | | 3 || 6 || 9
| + | |
− | |-
| + | |
− | ! scope="row" | 4
| + | |
− | | 4 || 8 || 12
| + | |
− | |-
| + | |
− | ! scope="row" | 5
| + | |
− | | 5 || 10 || 15
| + | |
− | |}
| + | |
− | </nowiki></pre></div>
| + | |
− | </td><td> </td><td style="width:48%;">
| + | |
− | <div style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;">
| + | |
− | {| class="wikitable"
| + | |
− | |+ Multiplication table
| + | |
− | |-
| + | |
− | ! scope="col" | ×
| + | |
− | ! scope="col" | 1
| + | |
− | ! scope="col" | 2
| + | |
− | ! scope="col" | 3
| + | |
− | |-
| + | |
− | ! scope="row" | 1
| + | |
− | | 1 || 2 || 3
| + | |
− | |-
| + | |
− | ! scope="row" | 2
| + | |
− | | 2 || 4 || 6
| + | |
− | |-
| + | |
− | ! scope="row" | 3
| + | |
− | | 3 || 6 || 9
| + | |
− | |-
| + | |
− | ! scope="row" | 4
| + | |
− | | 4 || 8 || 12
| + | |
− | |-
| + | |
− | ! scope="row" | 5
| + | |
− | | 5 || 10 || 15
| + | |
− | |}
| + | |
− | </div></td></tr></table>
| + | |