「ヘルプ:Tables」の版間の差分

提供: ひつじ小屋別館2代目
移動先: 案内検索
(adding Alignment)
(1版 をインポートしました)
 
(8人の利用者による、間の22版が非表示)
1行目: 1行目:
{{PD Help Page}}
+
<languages/>
:''For MediaWiki's database table structure, see: [[Manual:Database layout]]''
+
{{TNT|PD Help Page}}
 +
:''<translate><!--T:1-->
 +
For MediaWiki's database table structure, see <tvar|1>{{ll|Manual:Database layout}}</></translate>''
  
'''Tables''' may be created in wiki pages. As a general rule, it is best to avoid using a table unless you need one. Table markup often complicates page editing.<ref>Tables can be created using either XHTML table elements directly, or using wikicode formatting to define the table. XHTML table elements and their use are well described on various web pages and will not be discussed here. The benefit of wikicode is that the table is constructed of character symbols which tend to make it easier to perceive the table structure in the article editing view compared to XHTML table elements.</ref>  
+
<translate>
 +
<!--T:2-->
 +
'''Tables''' may be created in wiki pages.</translate>
 +
<translate>
 +
<!--T:3-->
 +
As a general rule, it is best to avoid using a table unless you need one.</translate>
 +
<translate>
 +
<!--T:4-->
 +
Table markup often complicates page editing.</translate><ref><translate><!--T:5-->
 +
Tables can be created using either XHTML table elements directly, or using wikicode formatting to define the table.</translate>
 +
<translate>
 +
<!--T:6-->
 +
XHTML table elements and their use are well described on various web pages and will not be discussed here.</translate>
 +
<translate>
 +
<!--T:7-->
 +
The benefit of wikicode is that the table is constructed of character symbols which tend to make it easier to perceive the table structure in the article editing view compared to XHTML table elements.</translate></ref>
  
 
+
<translate>
== Wiki table markup summary ==
+
== Wiki table markup summary == <!--T:8-->
{| class="wikitable" width="60%"
+
</translate>
 +
{| class="wikitable" style="width:60%"
 
| style="padding: 10px;"| <big><nowiki>{|</nowiki></big>
 
| style="padding: 10px;"| <big><nowiki>{|</nowiki></big>
| style="padding: 5px;"| '''table start'''
+
| style="padding: 5px;"| <translate><!--T:9-->
 +
'''table start''', ''required''</translate>
 
|-
 
|-
 
| style="padding: 10px;"| <big><nowiki>|+</nowiki></big>
 
| style="padding: 10px;"| <big><nowiki>|+</nowiki></big>
| style="padding: 5px;"| table '''caption,''' ''optional;'' only between '''table start''' and first '''table row'''
+
| style="padding: 5px;" | <translate><!--T:10-->
 +
table '''caption''', ''optional;'' only between '''table start''' and '''table row'''</translate>
 
|-
 
|-
 
| style="padding: 10px;"| <big><nowiki>|-</nowiki></big>
 
| style="padding: 10px;"| <big><nowiki>|-</nowiki></big>
| style="padding: 5px;"| '''table row,''' ''optional on first row'' -- wiki engine assumes the first row
+
| style="padding: 5px;" | <translate><!--T:11-->
 +
'''table row''', ''optional on first row''—wiki engine assumes the first row</translate>
 
|-
 
|-
 
| style="padding: 10px;"| <big><nowiki>!</nowiki></big>  
 
| style="padding: 10px;"| <big><nowiki>!</nowiki></big>  
| style="padding: 5px;"| '''table header''' cell, ''optional.'' Consecutive '''table header''' cells may be added on same line separated by double marks (<code>!!</code>) or start on new lines, each with its own single mark (<code>!</code>).
+
| style="padding: 5px;" | <translate><!--T:12-->
 +
'''table header''' cell, ''optional.''</translate> <translate><!--T:13-->
 +
Consecutive '''table header''' cells may be added on same line separated by double marks (<code>!!</code>) or start on new lines, each with its own single mark (<code>!</code>).</translate>
 
|-  
 
|-  
 
| style="padding: 10px;"| <big><nowiki>|</nowiki></big>
 
| style="padding: 10px;"| <big><nowiki>|</nowiki></big>
| style="padding: 5px;"| '''table data''' cell, ''required!'' Consecutive '''table data''' cells may be added on same line separated by double marks (<code><nowiki>||</nowiki></code>) or start on new lines, each with its own single mark (<code><nowiki>|</nowiki></code>).
+
| style="padding: 5px;" | <translate><!--T:14-->
 +
'''table data''' cell, ''optional''.</translate> <translate><!--T:15-->
 +
Consecutive '''table data''' cells may be added on same line separated by double marks (<code><nowiki>||</nowiki></code>) or start on new lines, each with its own single mark (<code><nowiki>|</nowiki></code>).</translate>
 
|-
 
|-
 
| style="padding: 10px;"| <big><nowiki>|}</nowiki></big>
 
| style="padding: 10px;"| <big><nowiki>|}</nowiki></big>
| style="padding: 5px;"| '''table end'''  
+
| style="padding: 5px;" | <translate><!--T:379-->
 +
'''table end''', ''required''</translate>
 
|}
 
|}
*The above marks must '''start on a new line''' except the double <code>||</code> and <code>!!</code> for optionally adding consecutive cells to a line. However, blank spaces at the beginning of a line are ignored.
+
<translate>
*'''XHTML attributes.''' Each mark, except table end, optionally accepts one or more XHTML attributes. Attributes must be on the same line as the mark. Separate attributes from each other with a single space.  
+
<!--T:16-->
**Cells and caption (<code>|</code> or <code>||</code>, <code>!</code> or <code>!!</code>, and <code>|+</code>) hold content. So separate any attributes from content with a single pipe (<code>|</code>). Cell content may follow on same line or on following lines.
+
*The above marks must '''start on a new line''' except the double <code>||</code> and <code>!!</code> for optionally adding consecutive cells to a line. However, blank spaces at the beginning of a line are ignored.</translate>
**Table and row marks (<code>{|</code> and <code>|-</code>) do not directly hold content. Do ''not'' add pipe (<code>|</code>) after their optional attributes. If you erroneously add a pipe after attributes for the table mark or row mark the parser will delete it ''and'' your final attribute if it was touching the erroneous pipe!
+
*'''<translate><!--T:17-->
*'''Content''' may (a) follow its cell mark on the same line after any optional XHTML attributes or (b) on lines below the cell mark. Content that uses wiki markup that itself needs to start on a new line, such as lists, headings, or nested tables, must be on its own new line.
+
XHTML attributes.</translate>''' <translate><!--T:18-->
**'''Pipe character as content.''' To insert a pipe (<code>|</code>) character into a table, use the &lt;nowiki&gt;<code>|</code>&lt;/nowiki&gt; escaping markup.
+
Each mark, except table end, optionally accepts one or more XHTML attributes.</translate> <translate><!--T:19-->
 +
Attributes must be on the same line as the mark.</translate> <translate><!--T:20-->
 +
Separate attributes from each other with a single space.</translate>
 +
<translate>
 +
<!--T:21-->
 +
**Cells and caption (<code>|</code> or <code>||</code>, <code>!</code> or <code>!!</code>, and <code>|+</code>) hold content.</translate> <translate><!--T:22-->
 +
So separate any attributes from content with a single pipe (<code>|</code>).</translate> <translate><!--T:23-->
 +
Cell content may follow on same line or on following lines.</translate>
 +
<translate>
 +
<!--T:24-->
 +
**Table and row marks (<code>{|</code> and <code>|-</code>) do not directly hold content.</translate> <translate><!--T:25-->
 +
Do ''not'' add pipe (<code>|</code>) after their optional attributes.</translate> <translate><!--T:26-->
 +
If you erroneously add a pipe after attributes for the table mark or row mark the parser will delete it ''and'' your final attribute if it was touching the erroneous pipe!</translate>
 +
<translate>
 +
<!--T:27-->
 +
*'''Content''' may (a) follow its cell mark on the same line after any optional XHTML attributes or (b) on lines below the cell mark.</translate> <translate><!--T:28-->
 +
Content that uses wiki markup that itself needs to start on a new line, such as lists, headings, or nested tables, must be on its own new line.</translate>
 +
<translate>
 +
<!--T:29-->
 +
**'''Pipe character as content.'''</translate> <translate><!--T:30-->
 +
To insert a pipe (<code>|</code>) character into a table, use the &lt;nowiki&gt;<code>|</code>&lt;/nowiki&gt; escaping markup.</translate>
  
==Basics==
+
<translate>
The following table lacks borders and good spacing but shows the simplest wiki markup table structure.
+
==Basics== <!--T:31--></translate>
 +
<translate>
 +
<!--T:32-->
 +
The following table lacks borders and good spacing but shows the simplest wiki markup table structure.</translate>
  
{| width="100%"
+
{| style="width:100%"
! style="width: 50%;"|You type
+
! style="width: 50%;"|<translate><!--T:404-->
! style="width: 50%;"|You get
+
You type</translate>
 +
! style="width: 50%;"|<translate><!--T:405-->
 +
You get</translate>
 
|-
 
|-
 
| style="padding: 5px;"|
 
| style="padding: 5px;"|
 
<pre>
 
<pre>
 
{|
 
{|
|Orange
+
|<translate><!--T:33-->
|Apple
+
Orange</translate>
 +
|<translate><!--T:34-->
 +
Apple</translate>
 
|-
 
|-
|Bread
+
|<translate><!--T:35-->
|Pie
+
Bread</translate>
 +
|<translate><!--T:36-->
 +
Pie</translate>
 
|-
 
|-
|Butter
+
|<translate><!--T:37-->
|Ice cream  
+
Butter</translate>
 +
|<translate><!--T:38-->
 +
Ice cream</translate>
 
|}
 
|}
 
</pre>
 
</pre>
 
| style="padding: 5px;"|
 
| style="padding: 5px;"|
 
{|
 
{|
|Orange
+
|<translate><!--T:39-->
|Apple
+
Orange</translate>
 +
|<translate><!--T:40-->
 +
Apple</translate>
 
|-
 
|-
|Bread
+
|<translate><!--T:41-->
|Pie
+
Bread</translate>
 +
|<translate><!--T:42-->
 +
Pie</translate>
 
|-
 
|-
|Butter
+
|<translate><!--T:43-->
|Ice cream  
+
Butter</translate>
 +
|<translate><!--T:44-->
 +
Ice cream</translate>
 
|}
 
|}
 
|}
 
|}
  
The cells in the same row can be listed on one line separated by <code>||</code> (two pipe symbols). If the text in the cell should contain a line break, use <code><nowiki><br/></nowiki></code> instead.
+
<translate>
 +
<!--T:45-->
 +
The cells in the same row can be listed on one line separated by <code>||</code> (two pipe symbols).</translate>
 +
<translate>
 +
<!--T:46-->
 +
If the text in the cell should contain a line break, use <tvar|br><code><nowiki><br /></nowiki></code></> instead.</translate>
  
{| width="100%"
+
{| style="width:100%"
! style="width: 50%;"|You type
+
! style="width: 50%;"|<translate><!--T:406-->
! style="width: 50%;"|You get
+
You type</translate>
 +
! style="width: 50%;"|<translate><!--T:407-->
 +
You get</translate>
 
|-
 
|-
 
| style="padding: 5px;"|
 
| style="padding: 5px;"|
 
<pre>
 
<pre>
 
{|
 
{|
|Orange||Apple||more
+
|<translate><!--T:47-->
 +
Orange</translate>||<translate><!--T:392-->
 +
Apple</translate>||<translate><!--T:393-->
 +
more</translate>
 
|-
 
|-
|Bread||Pie||more
+
|<translate><!--T:48-->
 +
Bread</translate>||<translate><!--T:394-->
 +
Pie</translate>||<translate><!--T:395-->
 +
more</translate>
 
|-
 
|-
|Butter||Ice<br/>cream||and<br/>more
+
|<translate><!--T:49-->
 +
Butter</translate>||<translate><!--T:396-->
 +
Ice<br />cream</translate>||<translate><!--T:403-->
 +
and<br />more</translate>
 
|}
 
|}
 
</pre>
 
</pre>
 
| style="padding: 5px;"|
 
| style="padding: 5px;"|
 
{|
 
{|
|Orange||Apple||more
+
|<translate><!--T:50-->
 +
Orange</translate>||<translate><!--T:397-->
 +
Apple</translate>||<translate><!--T:398-->
 +
more</translate>
 
|-
 
|-
|Bread||Pie||more
+
|<translate><!--T:51-->
 +
Bread</translate>||<translate><!--T:399-->
 +
Pie</translate>||<translate><!--T:400-->
 +
more</translate>
 
|-
 
|-
|Butter||Ice<br/>cream||and<br/>more
+
|<translate><!--T:52-->
 +
Butter</translate>||<translate><!--T:401-->
 +
Ice<br />cream</translate>||<translate><!--T:402-->
 +
and<br />more</translate>
 
|}
 
|}
 
|}
 
|}
  
Extra spaces within cells in the wiki markup, as in the wiki markup below, do not affect the actual table rendering.
+
<translate>
 +
<!--T:53-->
 +
Extra spaces within cells in the wiki markup, as in the wiki markup below, do not affect the actual table rendering.</translate>
  
{| width="100%"
+
{| style="width:100%"
! style="width: 50%;"|You type
+
! style="width: 50%;"|<translate><!--T:408-->
! style="width: 50%;"|You get
+
You type</translate>
 +
! style="width: 50%;"|<translate><!--T:409-->
 +
You get</translate>
 
|-
 
|-
 
| style="padding: 5px;"|
 
| style="padding: 5px;"|
 
<pre>
 
<pre>
 
{|
 
{|
|  Orange   ||   Apple   ||   more
+
<translate><!--T:54-->
 +
Orange</translate> || <translate><!--T:380-->
 +
Apple</translate> || <translate><!--T:381-->
 +
more</translate>
 
|-
 
|-
|  Bread   ||   Pie     ||   more
+
<translate><!--T:55-->
 +
Bread</translate> || <translate><!--T:382-->
 +
Pie</translate> || <translate><!--T:383-->
 +
more</translate>
 
|-
 
|-
|  Butter   || Ice cream || and more
+
<translate><!--T:56-->
 +
Butter</translate> || <translate><!--T:384-->
 +
Ice cream</translate> || <translate><!--T:385-->
 +
and more</translate>
 
|}
 
|}
 
</pre>
 
</pre>
 
| style="padding: 5px;"|
 
| style="padding: 5px;"|
 
{|
 
{|
|  Orange   ||   Apple   ||   more
+
<translate><!--T:57-->
 +
Orange</translate> || <translate><!--T:386-->
 +
Apple</translate> || <translate><!--T:387-->
 +
more</translate>
 
|-
 
|-
|  Bread   ||   Pie     ||   more
+
<translate><!--T:58-->
 +
Bread</translate> || <translate><!--T:388-->
 +
Pie</translate> || <translate><!--T:389-->
 +
more</translate>
 
|-
 
|-
|  Butter   || Ice cream || and more
+
<translate><!--T:59-->
 +
Butter</translate> || <translate><!--T:390-->
 +
Ice cream</translate> || <translate><!--T:391-->
 +
and more</translate>
 
|}
 
|}
 
|}
 
|}
  
You can have longer text or more complex wiki syntax inside table cells, too:
+
<translate>
 +
<!--T:60-->
 +
You can have longer text or more complex wiki syntax inside table cells, too:</translate>
  
{| width="100%"
+
{| style="width:100%"
! style="width: 50%;"|You type
+
! style="width: 50%;"|<translate><!--T:410-->
! style="width: 50%;"|You get
+
You type</translate>
 +
! style="width: 50%;"|<translate><!--T:411-->
 +
You get</translate>
 
|-
 
|-
 
| style="padding: 5px;"|
 
| style="padding: 5px;"|
161行目: 275行目:
 
|}
 
|}
  
=== Table headers ===
+
<translate>
Table headers can be created by using "<code>!</code>" (exclamation mark) instead of "<code>|</code>" (pipe symbol). Headers usually show up bold and centered by default.
+
=== Table headers === <!--T:61--></translate>
 +
<translate>
 +
<!--T:62-->
 +
Table headers can be created by using "<code>!</code>" (exclamation mark) instead of "<code>|</code>" (pipe symbol).</translate>
 +
<translate>
 +
<!--T:63-->
 +
Headers usually show up bold and centered by default.</translate>
  
{| width="100%"
+
{| style="width:100%"
! style="width: 50%;"|You type
+
! style="width: 50%;"|<translate><!--T:64-->
! style="width: 50%;"|You get
+
You type</translate>
 +
! style="width: 50%;"|<translate><!--T:65-->
 +
You get</translate>
 
|-
 
|-
 
| style="padding: 5px;"|
 
| style="padding: 5px;"|
 
<pre>
 
<pre>
 
{|
 
{|
! style="text-align:left;"| Item
+
! style="text-align:left;"| <translate><!--T:66-->
! Amount
+
Item</translate>
! Cost
+
! <translate><!--T:67-->
 +
Amount</translate>
 +
! <translate><!--T:68-->
 +
Cost</translate>
 
|-
 
|-
|Orange
+
|<translate><!--T:69-->
 +
Orange</translate>
 
|10
 
|10
 
|7.00
 
|7.00
 
|-
 
|-
|Bread
+
|<translate><!--T:70-->
 +
Bread</translate>
 
|4
 
|4
 
|3.00
 
|3.00
 
|-
 
|-
|Butter
+
|<translate><!--T:71-->
 +
Butter</translate>
 
|1
 
|1
 
|5.00
 
|5.00
 
|-
 
|-
!Total
+
!<translate><!--T:72-->
 +
Total</translate>
 
|
 
|
 
|15.00
 
|15.00
194行目: 323行目:
 
| style="padding: 5px;"|
 
| style="padding: 5px;"|
 
{|
 
{|
! style="text-align:left;"| Item
+
! style="text-align:left;"| <translate><!--T:73-->
! Amount
+
Item</translate>
! Cost
+
! <translate><!--T:74-->
 +
Amount</translate>
 +
! <translate><!--T:75-->
 +
Cost</translate>
 
|-
 
|-
|Orange
+
|<translate><!--T:76-->
 +
Orange</translate>
 
|10
 
|10
 
|7.00
 
|7.00
 
|-
 
|-
|Bread
+
|<translate><!--T:77-->
 +
Bread</translate>
 
|4
 
|4
 
|3.00
 
|3.00
 
|-
 
|-
|Butter
+
|<translate><!--T:78-->
 +
Butter</translate>
 
|1
 
|1
 
|5.00
 
|5.00
 
|-
 
|-
!Total
+
!<translate><!--T:79-->
 +
Total</translate>
 
|
 
|
 
|15.00
 
|15.00
216行目: 352行目:
 
|}
 
|}
  
'''Note:''' When using attributes as in the heading 'Item' a vertical bar '|' is used for separation. Not an exclamation character '!'.
+
<translate>
 +
<!--T:80-->
 +
'''Note:''' When using attributes as in the heading 'Item' a vertical bar '|' is used for separation.</translate>
 +
<translate>
 +
<!--T:81-->
 +
Not an exclamation character '!'.</translate>
  
===Caption===
+
<translate>
A '''table caption''' can be added to the top of any table as follows.
+
===Caption=== <!--T:82--></translate>
 +
<translate>
 +
<!--T:83-->
 +
A '''table caption''' can be added to the top of any table as follows.</translate>
  
{| width="100%"
+
{| style="width:100%"
! style="width: 50%;"|You type
+
! style="width: 50%;"|<translate><!--T:84-->
! style="width: 50%;"|You get
+
You type</translate>
 +
! style="width: 50%;"|<translate><!--T:85-->
 +
You get</translate>
 
|-
 
|-
 
| style="padding: 5px;"|
 
| style="padding: 5px;"|
 
<pre>
 
<pre>
 
{|
 
{|
|+Food complements
+
|+<translate><!--T:86-->
 +
Food complements</translate>
 
|-
 
|-
|Orange
+
|<translate><!--T:87-->
|Apple
+
Orange</translate>
 +
|<translate><!--T:88-->
 +
Apple</translate>
 
|-
 
|-
|Bread
+
|<translate><!--T:89-->
|Pie
+
Bread</translate>
 +
|<translate><!--T:90-->
 +
Pie</translate>
 
|-
 
|-
|Butter
+
|<translate><!--T:91-->
|Ice cream  
+
Butter</translate>
 +
|<translate><!--T:92-->
 +
Ice cream</translate>
 
|}
 
|}
 
</pre>
 
</pre>
 
| style="padding: 5px;"|
 
| style="padding: 5px;"|
 
{|
 
{|
|+ Food complements
+
|+ <translate><!--T:93-->
 +
Food complements</translate>
 
|-
 
|-
|Orange
+
|<translate><!--T:94-->
|Apple
+
Orange</translate>
 +
|<translate><!--T:95-->
 +
Apple</translate>
 
|-
 
|-
|Bread
+
|<translate><!--T:96-->
|Pie
+
Bread</translate>
 +
|<translate><!--T:97-->
 +
Pie</translate>
 
|-
 
|-
|Butter
+
|<translate><!--T:98-->
|Ice cream  
+
Butter</translate>
 +
|<translate><!--T:99-->
 +
Ice cream</translate>
 
|}
 
|}
 
|}
 
|}
  
===class="wikitable"===
+
<translate>
Basic styling (light gray background, borders, padding and align left) can be achieved by adding class="wikitable".
+
=== class="wikitable" === <!--T:100-->
 +
 
 +
<!--T:101-->
 +
Basic styling (light gray background, borders, padding and align left) can be achieved by adding class="wikitable".</translate>
  
{| width="100%"
+
{| style="width:100%"
! style="width: 50%;"|You type
+
! style="width: 50%;"|<translate><!--T:102-->
! style="width: 50%;"|You get
+
You type</translate>
 +
! style="width: 50%;"|<translate><!--T:103-->
 +
You get</translate>
 
|-
 
|-
 
| style="padding: 5px;"|
 
| style="padding: 5px;"|
 
<pre>
 
<pre>
 
{| class="wikitable"
 
{| class="wikitable"
|+Food complements
+
|+<translate><!--T:104-->
 +
Food complements</translate>
 
|-
 
|-
|Orange
+
|<translate><!--T:105-->
|Apple
+
Orange</translate>
 +
|<translate><!--T:106-->
 +
Apple</translate>
 
|-
 
|-
|Bread
+
|<translate><!--T:107-->
|Pie
+
Bread</translate>
 +
|<translate><!--T:108-->
 +
Pie</translate>
 
|-
 
|-
|Butter
+
|<translate><!--T:109-->
|Ice cream  
+
Butter</translate>
 +
|<translate><!--T:110-->
 +
Ice cream</translate>
 
|}
 
|}
 
</pre>
 
</pre>
 
| style="padding: 5px;"|
 
| style="padding: 5px;"|
 
{| class="wikitable"
 
{| class="wikitable"
|+ Food complements
+
|+ <translate><!--T:111-->
 +
Food complements</translate>
 
|-
 
|-
|Orange
+
|<translate><!--T:112-->
|Apple
+
Orange</translate>
 +
|<translate><!--T:113-->
 +
Apple</translate>
 
|-
 
|-
|Bread
+
|<translate><!--T:114-->
|Pie
+
Bread</translate>
 +
|<translate><!--T:115-->
 +
Pie</translate>
 
|-
 
|-
|Butter
+
|<translate><!--T:116-->
|Ice cream  
+
Butter</translate>
 +
|<translate><!--T:117-->
 +
Ice cream</translate>
 
|}
 
|}
 
|}
 
|}
  
===HTML colspan and rowspan===
+
<translate>
 +
===HTML colspan and rowspan=== <!--T:118--></translate>
  
You can use HTML '''colspan''' and '''rowspan''' attributes on cells for advanced layout.
+
<translate>
 +
<!--T:119-->
 +
You can use HTML '''colspan''' and '''rowspan''' attributes on cells for advanced layout.</translate>
  
{| width="100%"
+
{| style="width:100%"
! style="width: 50%;"|You type
+
! style="width: 50%;"|<translate><!--T:412-->
! style="width: 50%;"|You get
+
You type</translate>
 +
! style="width: 50%;"|<translate><!--T:413-->
 +
You get</translate>
 
|-
 
|-
 
| style="padding: 5px;"|
 
| style="padding: 5px;"|
 
<pre>
 
<pre>
 
{| class="wikitable"
 
{| class="wikitable"
!colspan="6"|Shopping List
+
!colspan="6"|<translate><!--T:120-->
 +
Shopping List</translate>
 
|-
 
|-
|rowspan="2"|Bread & Butter
+
|rowspan="2"|<translate><!--T:121-->
|Pie
+
Bread & Butter</translate>
|Buns
+
|<translate><!--T:122-->
|Danish
+
Pie</translate>
|colspan="2"|Croissant
+
|<translate><!--T:123-->
 +
Buns</translate>
 +
|<translate><!--T:124-->
 +
Danish</translate>
 +
|colspan="2"|<translate><!--T:125-->
 +
Croissant</translate>
 
|-
 
|-
|Cheese
+
|<translate><!--T:126-->
|colspan="2"|Ice cream
+
Cheese</translate>
|Butter
+
|colspan="2"|<translate><!--T:127-->
|Yogurt
+
Ice cream</translate>
 +
|<translate><!--T:128-->
 +
Butter</translate>
 +
|<translate><!--T:129-->
 +
Yogurt</translate>
 
|}
 
|}
 
</pre>
 
</pre>
 
| style="padding: 5px;"|
 
| style="padding: 5px;"|
 
{| class="wikitable"
 
{| class="wikitable"
!colspan="6"|Shopping List
+
!colspan="6"|<translate><!--T:130-->
 +
Shopping List</translate>
 
|-
 
|-
|rowspan="2"|Bread & Butter
+
|rowspan="2"|<translate><!--T:131-->
|Pie
+
Bread & Butter</translate>
|Buns
+
|<translate><!--T:132-->
|Danish
+
Pie</translate>
|colspan="2"|Croissant
+
|<translate><!--T:133-->
 +
Buns</translate>
 +
|<translate><!--T:134-->
 +
Danish</translate>
 +
|colspan="2"|<translate><!--T:135-->
 +
Croissant</translate>
 
|-
 
|-
|Cheese
+
|<translate><!--T:136-->
|colspan="2"|Ice cream
+
Cheese</translate>
|Butter
+
|colspan="2"|<translate><!--T:137-->
|Yogurt
+
Ice cream</translate>
 +
|<translate><!--T:138-->
 +
Butter</translate>
 +
|<translate><!--T:139-->
 +
Yogurt</translate>
 
|}
 
|}
 
|}
 
|}
  
== XHTML attributes ==
+
<translate>
You can add XHTML attributes to tables. For the authoritative source on these, see [http://www.w3.org/TR/REC-html40/struct/tables.html the W3C's HTML 4.01 Specification page on tables].
+
== XHTML attributes == <!--T:140--></translate>
 +
<translate>
 +
<!--T:141-->
 +
You can add XHTML attributes to tables.</translate>
 +
<translate>
 +
<!--T:142-->
 +
For the authoritative source on these, see [<tvar|url>https://www.w3.org/TR/html-markup/table.html</> the W3C's HTML Specification page on tables].</translate>
  
=== Attributes on tables ===
+
<translate>
Placing attributes after the table start tag (<code>{|</code>) applies attributes to the entire table.
+
=== Attributes on tables === <!--T:143--></translate>
 +
<translate>
 +
<!--T:144-->
 +
Placing attributes after the table start tag (<code>{|</code>) applies attributes to the entire table.</translate>
  
{| width="100%"
+
{| style="width:100%"
! style="width: 50%;"| You type
+
! style="width: 50%;"| <translate><!--T:145-->
! style="width: 50%;"| You get
+
You type</translate>
 +
! style="width: 50%;"| <translate><!--T:146-->
 +
You get</translate>
 
|-
 
|-
 
| style="padding: 5px;"|
 
| style="padding: 5px;"|
 
<pre>
 
<pre>
 
{| class="wikitable" style="text-align: center; color: green;"
 
{| class="wikitable" style="text-align: center; color: green;"
|Orange
+
|<translate><!--T:147-->
|Apple
+
Orange</translate>
 +
|<translate><!--T:148-->
 +
Apple</translate>
 
|12,333.00
 
|12,333.00
 
|-
 
|-
|Bread
+
|<translate><!--T:149-->
|Pie
+
Bread</translate>
 +
|<translate><!--T:150-->
 +
Pie</translate>
 
|500.00
 
|500.00
 
|-
 
|-
|Butter
+
|<translate><!--T:151-->
|Ice cream
+
Butter</translate>
 +
|<translate><!--T:152-->
 +
Ice cream</translate>
 
|1.00
 
|1.00
 
|}
 
|}
362行目: 583行目:
 
| style="padding: 5px;"|
 
| style="padding: 5px;"|
 
{| class="wikitable" style="text-align: center; color: green;"
 
{| class="wikitable" style="text-align: center; color: green;"
|Orange
+
|<translate><!--T:153-->
|Apple
+
Orange</translate>
 +
|<translate><!--T:154-->
 +
Apple</translate>
 
|12,333.00
 
|12,333.00
 
|-
 
|-
|Bread
+
|<translate><!--T:155-->
|Pie
+
Bread</translate>
 +
|<translate><!--T:156-->
 +
Pie</translate>
 
|500.00
 
|500.00
 
|-
 
|-
|Butter
+
|<translate><!--T:157-->
|Ice cream
+
Butter</translate>
 +
|<translate><!--T:158-->
 +
Ice cream</translate>
 
|1.00
 
|1.00
 
|}
 
|}
 
|}
 
|}
  
=== Attributes on cells ===
+
<translate>
You can put attributes on individual '''cells'''. For example, numbers may look better aligned right.
+
=== Attributes on cells === <!--T:159--></translate>
 +
<translate>
 +
<!--T:160-->
 +
You can put attributes on individual '''cells'''.</translate>
 +
<translate>
 +
<!--T:161-->
 +
For example, numbers may look better aligned right.</translate>
  
{| width="100%"
+
{| style="width:100%"
! style="width: 50%;"| You type
+
! style="width: 50%;"| <translate><!--T:162-->
! style="width: 50%;"| You get
+
You type</translate>
 +
! style="width: 50%;"| <translate><!--T:163-->
 +
You get</translate>
 
|-
 
|-
 
| style="padding: 5px;"|
 
| style="padding: 5px;"|
 
<pre>
 
<pre>
 
{| class="wikitable"
 
{| class="wikitable"
| Orange
+
| <translate><!--T:164-->
| Apple
+
Orange</translate>
 +
| <translate><!--T:165-->
 +
Apple</translate>
 
| style="text-align:right;" | 12,333.00
 
| style="text-align:right;" | 12,333.00
 
|-
 
|-
| Bread
+
| <translate><!--T:166-->
| Pie
+
Bread</translate>
 +
| <translate><!--T:167-->
 +
Pie</translate>
 
| style="text-align:right;" | 500.00
 
| style="text-align:right;" | 500.00
 
|-
 
|-
| Butter
+
| <translate><!--T:168-->
| Ice cream
+
Butter</translate>
 +
| <translate><!--T:169-->
 +
Ice cream</translate>
 
| style="text-align:right;" | 1.00
 
| style="text-align:right;" | 1.00
 
|}
 
|}
401行目: 642行目:
 
| style="padding: 5px;"|
 
| style="padding: 5px;"|
 
{| class="wikitable" style="text-align:center"
 
{| class="wikitable" style="text-align:center"
| Orange
+
| <translate><!--T:170-->
| Apple
+
Orange</translate>
 +
| <translate><!--T:171-->
 +
Apple</translate>
 
| style="text-align:right;" | 12,333.00
 
| style="text-align:right;" | 12,333.00
 
|-
 
|-
| Bread
+
| <translate><!--T:172-->
| Pie
+
Bread</translate>
 +
| <translate><!--T:173-->
 +
Pie</translate>
 
| style="text-align:right;" | 500.00
 
| style="text-align:right;" | 500.00
 
|-
 
|-
| Butter
+
| <translate><!--T:174-->
| Ice cream
+
Butter</translate>
 +
| <translate><!--T:175-->
 +
Ice cream</translate>
 
| style="text-align:right;" | 1.00
 
| style="text-align:right;" | 1.00
 
|}
 
|}
 
|}
 
|}
  
You can also use '''cell''' attributes when you are listing multiple '''cells''' on a single line. Note that the '''cells''' are separated by <code>||</code>, and within each '''cell''' the attribute(s) and value are separated by <code>|</code>.
+
<translate>
 +
<!--T:176-->
 +
You can also use '''cell''' attributes when you are listing multiple '''cells''' on a single line.</translate>
 +
<translate>
 +
<!--T:177-->
 +
Note that the '''cells''' are separated by <code>||</code>, and within each '''cell''' the attribute(s) and value are separated by <code>|</code>.</translate>
  
{| width="100%"
+
{| style="width:100%"
! style="width: 50%;"| You type
+
! style="width: 50%;"| <translate><!--T:178-->
! style="width: 50%;"| You get
+
You type</translate>
 +
! style="width: 50%;"| <translate><!--T:179-->
 +
You get</translate>
 
|-
 
|-
 
| style="padding: 5px;"|
 
| style="padding: 5px;"|
 
<pre>
 
<pre>
 
{| class="wikitable"
 
{| class="wikitable"
| Orange || Apple    || style="text-align:right;" | 12,333.00
+
| <translate><!--T:180-->
 +
Orange</translate> || <translate><!--T:373-->
 +
Apple</translate>     || style="text-align:right;" | 12,333.00
 
|-
 
|-
| Bread || Pie      || style="text-align:right;" | 500.00
+
| <translate><!--T:181-->
 +
Bread</translate> || <translate><!--T:374-->
 +
Pie</translate>       || style="text-align:right;" | 500.00
 
|-
 
|-
| Butter || Ice cream || style="text-align:right;" | 1.00
+
| <translate><!--T:182-->
 +
Butter</translate> || <translate><!--T:375-->
 +
Ice cream</translate> || style="text-align:right;" | 1.00
 
|}
 
|}
 
</pre>
 
</pre>
 
| style="padding: 5px;"|
 
| style="padding: 5px;"|
 
{| class="wikitable"
 
{| class="wikitable"
| Orange || Apple    || style="text-align:right;" | 12,333.00
+
| <translate><!--T:183-->
 +
Orange</translate> || <translate><!--T:376-->
 +
Apple</translate>     || style="text-align:right;" | 12,333.00
 
|-
 
|-
| Bread || Pie      || style="text-align:right;" | 500.00
+
| <translate><!--T:184-->
 +
Bread</translate> || <translate><!--T:377-->
 +
Pie</translate>       || style="text-align:right;" | 500.00
 
|-
 
|-
| Butter || Ice cream || style="text-align:right;" | 1.00
+
| <translate><!--T:185-->
 +
Butter</translate> || <translate><!--T:378-->
 +
Ice cream</translate> || style="text-align:right;" | 1.00
 
|}
 
|}
 
|}
 
|}
  
===Attributes on rows===
+
<translate>
You can put attributes on individual '''rows''', too.
+
===Attributes on rows=== <!--T:186--></translate>
 +
<translate>
 +
<!--T:187-->
 +
You can put attributes on individual '''rows''', too.</translate>
  
{| width="100%"
+
{| style="width:100%"
! style="width: 50%;"|You type
+
! style="width: 50%;"|<translate><!--T:188-->
! style="width: 50%;"|You get
+
You type</translate>
 +
! style="width: 50%;"|<translate><!--T:189-->
 +
You get</translate>
 
|-
 
|-
 
| style="padding: 5px;"|
 
| style="padding: 5px;"|
 
<pre>
 
<pre>
 
{| class="wikitable"
 
{| class="wikitable"
| Orange
+
| <translate><!--T:190-->
| Apple
+
Orange</translate>
 +
| <translate><!--T:191-->
 +
Apple</translate>
 
| style="text-align:right;"| 12,333.00
 
| style="text-align:right;"| 12,333.00
 
|-
 
|-
| Bread
+
| <translate><!--T:192-->
| Pie
+
Bread</translate>
 +
| <translate><!--T:193-->
 +
Pie</translate>
 
| style="text-align:right;"| 500.00
 
| style="text-align:right;"| 500.00
 
|- style="font-style: italic; color: green;"
 
|- style="font-style: italic; color: green;"
| Butter
+
| <translate><!--T:194-->
| Ice cream
+
Butter</translate>
 +
| <translate><!--T:195-->
 +
Ice cream</translate>
 
| style="text-align:right;"| 1.00
 
| style="text-align:right;"| 1.00
 
|}
 
|}
466行目: 743行目:
 
| style="padding: 5px;"|
 
| style="padding: 5px;"|
 
{| class="wikitable"
 
{| class="wikitable"
| Orange
+
| <translate><!--T:196-->
| Apple
+
Orange</translate>
 +
| <translate><!--T:197-->
 +
Apple</translate>
 
| style="text-align:right;"| 12,333.00
 
| style="text-align:right;"| 12,333.00
 
|-
 
|-
| Bread
+
| <translate><!--T:198-->
| Pie
+
Bread</translate>
 +
| <translate><!--T:199-->
 +
Pie</translate>
 
| style="text-align:right;"| 500.00
 
| style="text-align:right;"| 500.00
 
|- style="font-style: italic; color: green;"
 
|- style="font-style: italic; color: green;"
| Butter
+
| <translate><!--T:200-->
| Ice cream
+
Butter</translate>
 +
| <translate><!--T:201-->
 +
Ice cream</translate>
 
| style="text-align:right;"| 1.00
 
| style="text-align:right;"| 1.00
 
|}
 
|}
 
|}
 
|}
  
===Simple one-pixel table border===
+
<translate>
An example of the above  one-pixel table border:<ref name="moredetailed">The default table formatting uses the "border-collapse: separate" model, which adds table cell spacing (which also separates the table outer border from its content cells). Even with a zero cellspacing, the borders of consecutive cells (and of the overall table container) will add up, so to get a one-pixel separation between cells, you need to selectively remove one or more of the four borders of cells.<br><br>
+
===Simple one-pixel table border=== <!--T:202--></translate>
 
+
<translate>
Such tables may be formatted more simply, using the "border-collapse: collapse" CSS property; in this table formatting model, the cellspacing attribute (or the CSS "border-spacing:" property) and the table's "padding:" CSS property is ignored and only the larger border of adjacent inner cells (or the table border for outer cells) will be used.</ref>
+
<!--T:203-->
 +
An example of a one-pixel table border:</translate>
  
{| width=100%
+
{| style="width:100%"
 
|-
 
|-
! You type  
+
! style="width:50%" | <translate><!--T:204-->
! You get  
+
You type</translate>
 +
! style="width:50%" | <translate><!--T:205-->
 +
You get</translate>
 
|-
 
|-
| width=50% style="padding: 5px;" |
+
| style="padding: 5px;" |
<pre style="font-size: 80%">
+
<pre>
{| style="border-collapse: separate;
+
{| border="1" style="border-collapse:collapse"
          border-spacing: 0;
+
| <translate><!--T:206-->
          border: 1px solid #000;
+
Orange</translate>
          padding: 0"
+
| <translate><!--T:207-->
|-
+
Apple</translate>
| style="border-style: solid; border-width: 0 1px 1px 0"|
 
Orange
 
| style="border-style: solid; border-width: 0 0 1px 0"|
 
Apple
 
 
|-
 
|-
| style="border-style: solid; border-width: 0 1px 0 0"|
+
| <translate><!--T:208-->
Bread
+
Bread</translate>
| style="border-style: solid; border-width: 0"|
+
| <translate><!--T:209-->
Pie
+
Pie</translate>
 
|}
 
|}
 
</pre>
 
</pre>
| width=50% style="padding: 20px;"|
+
| style="padding: 20px;"|
{| style="border-collapse: separate; border-spacing: 0; border: 1px solid #000; padding: 0"
+
{| border="1" style="border-collapse:collapse"
 +
| <translate><!--T:210-->
 +
Orange</translate>
 +
| <translate><!--T:211-->
 +
Apple</translate>
 
|-
 
|-
| style="border-style: solid; border-width: 0 1px 1px 0"| Orange
+
| <translate><!--T:212-->
| style="border-style: solid; border-width: 0 0 1px 0"| Apple
+
Bread</translate>
|-
+
| <translate><!--T:213-->
| style="border-style: solid; border-width: 0 1px 0 0"| Bread
+
Pie</translate>
| style="border-style: solid; border-width: 0"| Pie
+
|}
 
|}
 
|}
 +
 +
<translate>
 +
===Border width=== <!--T:214--></translate>
 +
<translate>
 +
<!--T:215-->
 +
If "border-width:" has only one number, it is for all four border sides:</translate>
 +
{| style="width:100%"
 
|-
 
|-
| style="padding: 5px;"|
+
! style="width:50%" | <translate><!--T:216-->
<pre style="font-size: 80%">
+
You type</translate>
{| style="border-collapse: collapse; border: 1px solid #000"
+
! style="width:50%" | <translate><!--T:217-->
 +
You get</translate>
 
|-
 
|-
| style="border-style: solid; border-width: 1px"|  
+
| style="padding: 5px;" |
Orange
+
<pre>
| style="border-style: solid; border-width: 1px"|
+
{|style="border-style: solid; border-width: 20px"
Apple
+
|
|-
+
<translate><!--T:218-->
| style="border-style: solid; border-width: 1px"|
+
Hello</translate>
Bread
 
| style="border-style: solid; border-width: 1px"|
 
Pie
 
 
|}
 
|}
 
</pre>
 
</pre>
 
| style="padding: 20px;"|
 
| style="padding: 20px;"|
{| style="border-collapse: collapse; border: 1px solid #000"
+
{|style="border-style: solid; border-width: 20px"
|-
+
|
| style="border-style: solid; border-width: 1px"| Orange
+
<translate><!--T:219-->
| style="border-style: solid; border-width: 1px"| Apple
+
Hello</translate>
|-
 
| style="border-style: solid; border-width: 1px"| Bread
 
| style="border-style: solid; border-width: 1px"| Pie
 
 
|}
 
|}
 
|}
 
|}
  
===Border width===
+
<translate>
If "border-width:" has only one number, it is for all four border sides:
+
<!--T:220-->
{| width=100%
+
If "border-width:" has more than one number, the four numbers are for '''top, right, bottom, left (REMEMBER this order)''':</translate>
 +
 
 +
{| style="width:100%"
 
|-
 
|-
! You type  
+
! style="width:50%" | <translate><!--T:221-->
! You get  
+
You type</translate>
 +
! style="width:50%" | <translate><!--T:222-->
 +
You get</translate>
 
|-
 
|-
| width=50% style="padding: 5px;" |
+
| style="padding: 5px;" |
 
<pre>
 
<pre>
{|style="border-style: solid; border-width: 20px"
+
{|style="border-style: solid; border-width: 10px 20px 100px 0"
 
|
 
|
Hello
+
<translate><!--T:223-->
 +
Hello</translate>
 
|}
 
|}
 
</pre>
 
</pre>
| width=50% style="padding: 20px;"|
+
| style="padding: 20px;"|
{|style="border-style: solid; border-width: 20px"
+
{|style="border-style: solid; border-width: 10px 20px 100px 0"
 
|
 
|
Hello
+
<translate><!--T:224-->
 +
Hello</translate>
 
|}
 
|}
 
|}
 
|}
  
If "border-width:" has more than one number, the four numbers are for top, right, bottom, left:
+
<translate>
 +
<!--T:225-->
 +
:When there are fewer than 4 values, the value for left takes its default from the value for right, the value for bottom takes its default from the value for top, and the value for right takes its default from the value for top.</translate>
  
{| width=100%
+
<translate>
 +
<!--T:226-->
 +
Another method to define the widths of the four sides of a cell is to use ''"border-left", "border-right", "border-top" and "border-bottom"'':</translate>
 +
<div style="width: 100%; overflow:auto;">
 +
{| style="width:100%"
 
|-
 
|-
! You type  
+
! style="width:50%" | <translate><!--T:227-->
! You get  
+
You type</translate>
 +
! style="width:50%" | <translate><!--T:228-->
 +
You get</translate>
 
|-
 
|-
| width=50% style="padding: 5px;" |
+
| style="padding: 5px;" |
 
<pre>
 
<pre>
{|style="border-style: solid; border-width: 10px 20px 100px 0"
+
{|style="border-left:solid 10px black;border-right:solid 20px black;border-top:solid 30px black;border-bottom:solid 40px black;" align="center"  
 
|
 
|
Hello
+
<translate><!--T:229-->
 +
Hello</translate>
 
|}
 
|}
 
</pre>
 
</pre>
| width=50% style="padding: 20px;"|
+
| style="padding: 20px;"|
{|style="border-style: solid; border-width: 10px 20px 100px 0"
+
{|style="border-left:solid 10px black;border-right:solid 20px black;border-top:solid 30px black;border-bottom:solid 40px black;" align="center"  
 
|
 
|
Hello
+
<translate><!--T:230-->
 +
Hello</translate>
 
|}
 
|}
 
|}
 
|}
 +
</div>
  
:When there are fewer than 4 values, the value for left takes its default from the value for right, the value for bottom takes its default from the value for top, and the value for right takes its default from the value for top.
+
{{TNT|Note}}
 +
<translate><!--T:231-->
 +
* The HTML attributes (such as "width=", "border=", "cellspacing=", "cellpadding=") do not need any length unit (the pixel unit is assumed).</translate> <translate><!--T:414-->
 +
They are also invalid in HTML 5.</translate>
 +
<translate>
 +
<!--T:232-->
 +
The CSS style properties (which override the HTML attributes) require an explicit length unit (if the value is not 0) such as "px" for the pixel.</translate>
  
Notes :
+
<translate>
* The HTML attributes (such as "width=", "border=", "cellspacing=", "cellpadding=") do not need any length unit (the pixel unit is assumed). The CSS style properties (which override the HTML attributes) require an explicit length unit (if the value is not 0) such as "px" for the pixel.
+
===With HTML attributes and CSS styles=== <!--T:233--></translate>
 +
<translate>
 +
<!--T:234-->
 +
[[Special:MyLanuage/Manual:CSS|CSS]] style attributes can be added with or without other HTML attributes.</translate>
  
===With HTML attributes and CSS styles===
+
{| style="width:100%"
[[Manual:CSS|CSS]] style attributes can be added with or without other HTML attributes.
+
! style="width: 50%;"|<translate><!--T:235-->
 
+
You type</translate>
{| width="100%"
+
! style="width: 50%;"|<translate><!--T:236-->
! style="width: 50%;"|You type
+
You get</translate>
! style="width: 50%;"|You get
 
 
|-
 
|-
 
| style="padding: 5px;"|
 
| style="padding: 5px;"|
 
<pre>
 
<pre>
 
{| class="wikitable" style="color:green; background-color:#ffffcc;" cellpadding="10"
 
{| class="wikitable" style="color:green; background-color:#ffffcc;" cellpadding="10"
|Orange
+
|<translate><!--T:237-->
|Apple
+
Orange</translate>
 +
|<translate><!--T:238-->
 +
Apple</translate>
 
|-
 
|-
|Bread
+
|<translate><!--T:239-->
|Pie
+
Bread</translate>
 +
|<translate><!--T:240-->
 +
Pie</translate>
 
|-
 
|-
|Butter
+
|<translate><!--T:241-->
|Ice cream  
+
Butter</translate>
 +
|<translate><!--T:242-->
 +
Ice cream</translate>
 
|}
 
|}
 
</pre>
 
</pre>
 
| style="padding: 5px;"|
 
| style="padding: 5px;"|
 
{| class="wikitable" style="color:green; background-color:#ffffcc;" cellpadding="10"  
 
{| class="wikitable" style="color:green; background-color:#ffffcc;" cellpadding="10"  
|Orange
+
|<translate><!--T:243-->
|Apple
+
Orange</translate>
 +
|<translate><!--T:244-->
 +
Apple</translate>
 
|-
 
|-
|Bread
+
|<translate><!--T:245-->
|Pie
+
Bread</translate>
 +
|<translate><!--T:246-->
 +
Pie</translate>
 
|-
 
|-
|Butter
+
|<translate><!--T:247-->
|Ice cream  
+
Butter</translate>
 +
|<translate><!--T:248-->
 +
Ice cream</translate>
 
|}
 
|}
 
|}
 
|}
  
====Attributes====
+
<translate>
'''Attributes''' can be added to the caption and headers as follows.
+
====Attributes==== <!--T:249--></translate>
 +
<translate>
 +
<!--T:250-->
 +
'''Attributes''' can be added to the caption and headers as follows.</translate>
  
{| width="100%"
+
{| style="width:100%"
! style="width: 50%;"|You type
+
! style="width: 50%;"|<translate><!--T:251-->
! style="width: 50%;"|You get
+
You type</translate>
 +
! style="width: 50%;"|<translate><!--T:252-->
 +
You get</translate>
 
|-
 
|-
 
| style="padding: 5px;"|
 
| style="padding: 5px;"|
 
<pre>
 
<pre>
 
{| class="wikitable"
 
{| class="wikitable"
|+ style="caption-side:bottom; color:#e76700;"|''Food complements''
+
|+ style="caption-side:bottom; color:#e76700;"|<translate><!--T:253-->
 +
''Food complements''</translate>
 
|-
 
|-
|Orange
+
|<translate><!--T:254-->
|Apple
+
Orange</translate>
 +
|<translate><!--T:255-->
 +
Apple</translate>
 
|-
 
|-
|Bread
+
|<translate><!--T:256-->
|Pie
+
Bread</translate>
 +
|<translate><!--T:257-->
 +
Pie</translate>
 
|-
 
|-
|Butter
+
|<translate><!--T:258-->
|Ice cream  
+
Butter</translate>
 +
|<translate><!--T:259-->
 +
Ice cream</translate>
 
|}
 
|}
 
</pre>
 
</pre>
 
| style="padding: 5px;"|
 
| style="padding: 5px;"|
 
{| class="wikitable"
 
{| class="wikitable"
|+ style="caption-side:bottom; color:#e76700;"|''Food complements''
+
|+ style="caption-side:bottom; color:#e76700;"|<translate><!--T:260-->
 +
''Food complements''</translate>
 
|-
 
|-
|Orange
+
|<translate><!--T:261-->
|Apple
+
Orange</translate>
 +
|<translate><!--T:262-->
 +
Apple</translate>
 
|-
 
|-
|Bread
+
|<translate><!--T:263-->
|Pie
+
Bread</translate>
 +
|<translate><!--T:264-->
 +
Pie</translate>
 
|-
 
|-
|Butter
+
|<translate><!--T:265-->
|Ice cream  
+
Butter</translate>
 +
|<translate><!--T:266-->
 +
Ice cream</translate>
 
|}
 
|}
 
|}
 
|}
  
====Column width====
+
<translate>
'''Column width''' can be added as follows.
+
====Column width==== <!--T:267--></translate>
 +
<translate>
 +
<!--T:268-->
 +
'''Column width''' can be added as follows.</translate>
  
You type:
+
<translate>
 +
<!--T:269-->
 +
You type:</translate>
 
<pre>
 
<pre>
{| style="color: black; background-color: #ffffcc;" width="85%"
+
{| style="color: black; background-color: #ffffcc; width: 85%;"
| colspan="2" | This column width is 85% of the screen width (and has a background color)
+
| colspan="2" | <translate><!--T:270-->
 +
This column width is 85% of the screen width (and has a background color)</translate>
 
|-
 
|-
 
| style="width: 30%; background-color: white;"|
 
| style="width: 30%; background-color: white;"|
'''This column is 30% counted from 85% of the screen width'''
+
<translate><!--T:271-->
 +
'''This column is 30% counted from 85% of the screen width'''</translate>
 
| style="width: 70%; background-color: orange;"|
 
| style="width: 70%; background-color: orange;"|
'''This column is 70% counted from 85% of the screen width (and has a background color)'''
+
<translate><!--T:272-->
 +
'''This column is 70% counted from 85% of the screen width (and has a background color)'''</translate>
 
|}
 
|}
 
</pre>
 
</pre>
  
You get:
+
<translate>
{| style="color: black; background-color: #ffffcc;" width="85%"  
+
<!--T:273-->
| colspan="2" | This column width is 85% of the screen width (and has a background color)
+
You get:</translate>
 +
{| style="color: black; background-color: #ffffcc; width: 85%;"
 +
| colspan="2" | <translate><!--T:274-->
 +
This column width is 85% of the screen width (and has a background color)</translate>
 
|-
 
|-
| style="width: 30%; background-color: white;"| '''This column is 30% counted from 85% of the screen width'''
+
| style="width: 30%; background-color: white;"| <translate><!--T:275-->
| style="width: 70%; background-color: orange;"| '''This column is 70% counted from 85% of the screen width (and has a background color)'''
+
'''This column is 30% counted from 85% of the screen width'''</translate>
 +
| style="width: 70%; background-color: orange;"| <translate><!--T:276-->
 +
'''This column is 70% counted from 85% of the screen width (and has a background color)'''</translate>
 
|}
 
|}
  
===Accessibility of table header cells===
+
<translate>
Table header cells do not explicitly specify which table data cells they apply to (those on their right on the same row, or those below them on the same column). When the table is rendered in a visual 2D environment, this is usually easy to infer.
+
===Accessibility of table header cells=== <!--T:277--></translate>
 +
<translate>
 +
<!--T:278-->
 +
Table header cells do not explicitly specify which table data cells they apply to (those on their right on the same row, or those below them on the same column).</translate>
 +
<translate>
 +
<!--T:279-->
 +
When the table is rendered in a visual 2D environment, this is usually easy to infer.</translate>
  
However when tables are rendered on non-visual media, you can help the browser to determine which table header cell applies to the description of any selected cell (in order to repeat its content in some accessibility helper) using a scope="row" or scope="col" attribute on table header cells. In most cases with simple tables, you'll use scope="col" on all header cells of the first row, and scope="row" on the first cell of the following rows:
+
<translate>
 +
<!--T:280-->
 +
However when tables are rendered on non-visual media, you can help the browser to determine which table header cell applies to the description of any selected cell (in order to repeat its content in some accessibility helper) using a scope="row" or scope="col" attribute on table header cells.</translate>
 +
<translate>
 +
<!--T:281-->
 +
In most cases with simple tables, you'll use scope="col" on all header cells of the first row, and scope="row" on the first cell of the following rows:</translate>
  
{| width="100%"
+
{| style="width:100%"
! style="width: 50%;"|You type
+
! style="width: 50%;"|<translate><!--T:282-->
! style="width: 50%;"|You get
+
You type</translate>
 +
! style="width: 50%;"|<translate><!--T:283-->
 +
You get</translate>
 
|-
 
|-
 
| style="padding: 5px;"|
 
| style="padding: 5px;"|
697行目: 1,067行目:
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
! scope="col"| Item
+
! scope="col"| <translate><!--T:284-->
! scope="col"| Quantity
+
Item</translate>
! scope="col"| Price
+
! scope="col"| <translate><!--T:285-->
 +
Quantity</translate>
 +
! scope="col"| <translate><!--T:286-->
 +
Price</translate>
 
|-
 
|-
! scope="row"| Bread
+
! scope="row"| <translate><!--T:287-->
 +
Bread</translate>
 
| 0.3 kg
 
| 0.3 kg
 
| $0.65
 
| $0.65
 
|-
 
|-
! scope="row"| Butter
+
! scope="row"| <translate><!--T:288-->
 +
Butter</translate>
 
| 0.125 kg
 
| 0.125 kg
 
| $1.25
 
| $1.25
 
|-
 
|-
! scope="row" colspan="2"| Total
+
! scope="row" colspan="2"| <translate><!--T:289-->
 +
Total</translate>
 
| $1.90
 
| $1.90
 
|}
 
|}
716行目: 1,092行目:
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
! scope="col"| Item
+
! scope="col"| <translate><!--T:290-->
! scope="col"| Quantity
+
Item</translate>
! scope="col"| Price
+
! scope="col"| <translate><!--T:291-->
 +
Quantity</translate>
 +
! scope="col"| <translate><!--T:292-->
 +
Price</translate>
 
|-
 
|-
! scope="row"| Bread
+
! scope="row"| <translate><!--T:293-->
 +
Bread</translate>
 
| 0.3 kg
 
| 0.3 kg
 
| $0.65
 
| $0.65
 
|-
 
|-
! scope="row"| Butter
+
! scope="row"| <translate><!--T:294-->
 +
Butter</translate>
 
| 0.125 kg
 
| 0.125 kg
 
| $1.25
 
| $1.25
 
|-
 
|-
! scope="row" colspan="2"| Total
+
! scope="row" colspan="2"| <translate><!--T:295-->
 +
Total</translate>
 
| $1.90
 
| $1.90
 
|}
 
|}
 
|}
 
|}
  
== Alignment ==
+
<translate>
 +
== Alignment == <!--T:296--></translate>
  
=== Table alignment ===
+
<translate>
 +
=== Table alignment === <!--T:297--></translate>
  
Table alignment is achieved by using CSS. The table alignment is controlled by margins. A fixed margin on one side will make the table to be aligned to that side, if on the opposite side the margin is defined as ''auto''. To have a table center aligned, you should set both margins to ''auto''
+
<translate>
 +
<!--T:298-->
 +
Table alignment is achieved by using CSS.</translate>
 +
<translate>
 +
<!--T:299-->
 +
The table alignment is controlled by margins.</translate>
 +
<translate>
 +
<!--T:300-->
 +
A fixed margin on one side will make the table to be aligned to that side, if on the opposite side the margin is defined as ''auto''.</translate>
 +
<translate>
 +
<!--T:301-->
 +
To have a table center aligned, you should set both margins to ''auto''</translate>
  
For example, a rigt-aligned table:
+
<translate>
 +
<!--T:302-->
 +
For example, a right-aligned table:</translate>
  
{| width="100%"
+
{| style="width:100%"
! style="width: 50%;"|You type
+
! style="width: 50%;"|<translate><!--T:303-->
! style="width: 50%;"|You get
+
You type</translate>
 +
! style="width: 50%;"|<translate><!--T:304-->
 +
You get</translate>
 
|-
 
|-
 
| style="padding: 5px;"|
 
| style="padding: 5px;"|
 
<pre>
 
<pre>
 
{| class="wikitable" style="margin-left: auto; margin-right: 0px;"
 
{| class="wikitable" style="margin-left: auto; margin-right: 0px;"
| Orange
+
| <translate><!--T:305-->
| Apple
+
Orange</translate>
 +
| <translate><!--T:306-->
 +
Apple</translate>
 
|-
 
|-
| Bread
+
| <translate><!--T:307-->
| Pie
+
Bread</translate>
 +
| <translate><!--T:308-->
 +
Pie</translate>
 
|-
 
|-
| Butter
+
| <translate><!--T:309-->
| Ice cream  
+
Butter</translate>
 +
| <translate><!--T:310-->
 +
Ice cream</translate>
 
|}
 
|}
 
</pre>
 
</pre>
 
| style="padding: 5px;"|
 
| style="padding: 5px;"|
 
{| class="wikitable" style="margin-left: auto; margin-right: 0px;"
 
{| class="wikitable" style="margin-left: auto; margin-right: 0px;"
| Orange
+
| <translate><!--T:311-->
| Apple
+
Orange</translate>
 +
| <translate><!--T:312-->
 +
Apple</translate>
 
|-
 
|-
| Bread
+
| <translate><!--T:313-->
| Pie
+
Bread</translate>
 +
| <translate><!--T:314-->
 +
Pie</translate>
 
|-
 
|-
| Butter
+
| <translate><!--T:315-->
| Ice cream  
+
Butter</translate>
 +
| <translate><!--T:316-->
 +
Ice cream</translate>
 
|}
 
|}
 
|}
 
|}
  
And a center-aligned table:
+
<translate>
 +
<!--T:317-->
 +
And a center-aligned table:</translate>
  
{| width="100%"
+
{| style="width:100%"
! style="width: 50%;"|You type
+
! style="width: 50%;"|<translate><!--T:318-->
! style="width: 50%;"|You get
+
You type</translate>
 +
! style="width: 50%;"|<translate><!--T:319-->
 +
You get</translate>
 
|-
 
|-
 
| style="padding: 5px;"|
 
| style="padding: 5px;"|
 
<pre>
 
<pre>
 
{| class="wikitable" style="margin: auto;"
 
{| class="wikitable" style="margin: auto;"
| Orange
+
| <translate><!--T:320-->
| Apple
+
Orange</translate>
 +
| <translate><!--T:321-->
 +
Apple</translate>
 
|-
 
|-
| Bread
+
| <translate><!--T:322-->
| Pie
+
Bread</translate>
 +
| <translate><!--T:323-->
 +
Pie</translate>
 
|-
 
|-
| Butter
+
| <translate><!--T:324-->
| Ice cream  
+
Butter</translate>
 +
| <translate><!--T:325-->
 +
Ice cream</translate>
 
|}
 
|}
 
</pre>
 
</pre>
 
| style="padding: 5px;"|
 
| style="padding: 5px;"|
 
{| class="wikitable" style="margin: auto;"
 
{| class="wikitable" style="margin: auto;"
| Orange
+
| <translate><!--T:326-->
| Apple
+
Orange</translate>
 +
| <translate><!--T:327-->
 +
Apple</translate>
 
|-
 
|-
| Bread
+
| <translate><!--T:328-->
| Pie
+
Bread</translate>
 +
| <translate><!--T:329-->
 +
Pie</translate>
 
|-
 
|-
| Butter
+
| <translate><!--T:330-->
| Ice cream  
+
Butter</translate>
 +
| <translate><!--T:331-->
 +
Ice cream</translate>
 
|}
 
|}
 
|}
 
|}
  
=== Table floating around text ===
+
<translate>
 +
=== Table floating around text === <!--T:332--></translate>
  
If you align a table to the right or the left side of the page, the text that comes after the table starts at the end of it, leaving an empty space around the table. You can make the text to be wrapped around the table by making the table to ''float'' around the text instead of just aligning it. This can be achieved using the <code>float</code> CSS attribute, which can specify where the table floats to the right side or to the left. When using ''float'', margins doesn't control table alignment and can be used to specify the margin between the table and the surrounding text.
+
<translate>
 +
<!--T:333-->
 +
If you align a table to the right or the left side of the page, the text that comes after the table starts at the end of it, leaving an empty space around the table.</translate>
 +
<translate>
 +
<!--T:334-->
 +
You can make the text to be wrapped around the table by making the table to ''float'' around the text instead of just aligning it.</translate>
 +
<translate>
 +
<!--T:335-->
 +
This can be achieved using the <code>float</code> CSS attribute, which can specify where the table floats to the right side or to the left.</translate>
 +
<translate>
 +
<!--T:336-->
 +
When using ''float'', margins doesn't control table alignment and can be used to specify the margin between the table and the surrounding text.</translate>
  
{| width="100%"
+
{| style="width:100%"
! style="width: 50%;"|You type
+
! style="width: 50%;"|<translate><!--T:337-->
! style="width: 50%;"|You get
+
You type</translate>
 +
! style="width: 50%;"|<translate><!--T:338-->
 +
You get</translate>
 
|-
 
|-
 
| style="padding: 5px;"|
 
| style="padding: 5px;"|
 
<pre>
 
<pre>
 
{| class="wikitable" style="float:right; margin-left: 10px;"
 
{| class="wikitable" style="float:right; margin-left: 10px;"
| Orange
+
| <translate><!--T:339-->
| Apple
+
Orange</translate>
 +
| <translate><!--T:340-->
 +
Apple</translate>
 
|-
 
|-
| Bread
+
| <translate><!--T:341-->
| Pie
+
Bread</translate>
 +
| <translate><!--T:342-->
 +
Pie</translate>
 
|-
 
|-
| Butter
+
| <translate><!--T:343-->
| Ice cream  
+
Butter</translate>
 +
| <translate><!--T:344-->
 +
Ice cream</translate>
 
|}
 
|}
  
838行目: 1,285行目:
 
| style="padding: 5px;"|
 
| style="padding: 5px;"|
 
{| class="wikitable" style="float:right; margin-left: 10px;"
 
{| class="wikitable" style="float:right; margin-left: 10px;"
| Orange
+
| <translate><!--T:345-->
| Apple
+
Orange</translate>
 +
| <translate><!--T:346-->
 +
Apple</translate>
 
|-
 
|-
| Bread
+
| <translate><!--T:347-->
| Pie
+
Bread</translate>
 +
| <translate><!--T:348-->
 +
Pie</translate>
 
|-
 
|-
| Butter
+
| <translate><!--T:349-->
| Ice cream  
+
Butter</translate>
 +
| <translate><!--T:350-->
 +
Ice cream</translate>
 
|}
 
|}
  
861行目: 1,314行目:
 
|}
 
|}
  
=== Cell contents alignment ===
+
<translate>
 +
=== Cell contents alignment === <!--T:351--></translate>
  
The alignment of cell contents can be controlled with 2 different CSS properties: <code>text-align</code> and <code>vertical-align</code>. <code>text-align</code> can be specified at the table, row or individual cells, while <code>vertical-align</code> only can be specified at individual rows or cells.
+
<translate>
 +
<!--T:352-->
 +
The alignment of cell contents can be controlled with 2 different CSS properties: <code>text-align</code> and <code>vertical-align</code>.</translate>
 +
<translate>
 +
<!--T:353-->
 +
<code>text-align</code> can be specified at the table, row or individual cells, while <code>vertical-align</code> only can be specified at individual rows or cells.</translate>
  
{| width="100%"
+
{| style="width:100%"
! style="width: 50%;"|You type
+
! style="width: 50%;"|<translate><!--T:354-->
! style="width: 50%;"|You get
+
You type</translate>
 +
! style="width: 50%;"|<translate><!--T:355-->
 +
You get</translate>
 
|-
 
|-
 
| style="padding: 5px;"|
 
| style="padding: 5px;"|
903行目: 1,364行目:
 
|}
 
|}
  
==Caveats==
+
<translate>
 +
==Caveats== <!--T:356--></translate>
  
===Negative numbers===
+
<translate>
If you start a cell on a new line with a negative number with a minus sign (or a parameter that evaluates to a negative number), your table can get broken, because the characters <code>|-</code> will be parsed as the wiki markup for table row, not table cell. To avoid this, insert a space before the value (<code>| -6</code>) or use in-line cell markup (<code>|| -6</code>).
+
===Negative numbers=== <!--T:357--></translate>
 +
<translate>
 +
<!--T:358-->
 +
If you start a cell on a new line with a negative number with a minus sign (or a parameter that evaluates to a negative number), your table can get broken, because the characters <code>|-</code> will be parsed as the wiki markup for table row, not table cell.</translate>
 +
<translate>
 +
<!--T:359-->
 +
To avoid this, insert a space before the value (<code>| -6</code>) or use in-line cell markup (<code>|| -6</code>).</translate>
  
===CSS vs attributes===
+
<translate>
Table borders specified through CSS rather than the border attribute will render incorrectly in a small subset of text browsers.
+
===CSS vs attributes=== <!--T:360--></translate>
 +
<translate>
 +
<!--T:361-->
 +
Table borders specified through CSS rather than the border attribute will render incorrectly in a small subset of text browsers.</translate>
  
===Common attributes for columns, column groups and row groups===
+
<translate>
The MediaWiki syntax for tables currently offers no support for specifying common attributes for columns (with the HTML element <code>&lt;col /&gt;</code>), column groups (HTML element <code>&lt;colgroup&gt;...&lt;/colgroup&gt;</code>) and row groups (HTML elements <code>&lt;thead&gt;...&lt;/thead&gt;</code>, <code>&lt;tbody&gt;...&lt;/tbody&gt;<code> and <code>&lt;tfoot&gt;...&lt;/tfoot&gt;</code>). Those standard HTML elements are not accepted even in their HTML or XHTML syntax.
+
===Common attributes for columns, column groups and row groups=== <!--T:362--></translate>
 +
<translate>
 +
<!--T:363-->
 +
The MediaWiki syntax for tables currently offers no support for specifying common attributes for columns (with the HTML element <code><nowiki><col /></nowiki></code>), column groups (HTML element <code><nowiki><colgroup></colgroup></nowiki></code>) and row groups (HTML elements <code><nowiki><thead></thead></nowiki></code>, <code><nowiki><tbody></tbody></nowiki><code> and <code><nowiki><tfoot></tfoot></nowiki></code>).</translate>
 +
<translate>
 +
<!--T:364-->
 +
Those standard HTML elements are not accepted even in their HTML or XHTML syntax.</translate>
  
All the rows and cells (header or data) of the table are rendered within a single implicit row group (HTML element <code>&lt;tbody&gt;...&lt;/tbody&gt;</code>) without any attributes or styles.
+
<translate>
 +
<!--T:365-->
 +
All the rows and cells (header or data) of the table are rendered within a single implicit row group (HTML element <code><nowiki><tbody></tbody></nowiki></code>) without any attributes or styles.</translate>
  
==See also==
+
<translate>
* [[Help:Sorting]]
+
==See also== <!--T:366--></translate>
 +
<translate>
 +
<!--T:367-->
 +
* [[Special:MyLanguage/Help:Sorting#Sorting rows of a table|Sorting rows of a table]]
 +
</translate>
 
* {{mediawiki|meta:Help:Sorting}}
 
* {{mediawiki|meta:Help:Sorting}}
 
* {{mediawiki|wikipedia:Help:Tables}}
 
* {{mediawiki|wikipedia:Help:Tables}}
==Notes==
+
<translate>
{{reflist}}
+
<!--T:370-->
 +
* [http://www.tablesgenerator.com/mediawiki_tables Easy tool that helps generating tables]</translate>
 +
<translate>
 +
<!--T:371-->
 +
* {{mediawiki|wikipedia:Template:Horizontal TOC}}. Good for country lists in table format.</translate>
 +
 
 +
<translate>
 +
==Notes== <!--T:372-->
 +
</translate>
 +
 
 +
<references/>
  
{{Languages}}
+
[[Category:Help{{#translation:}}|Tables]]
[[Category:Help|Tables]]
 

2016年7月24日 (日) 00:25時点における最新版

PD Note: When you edit this page, you agree to release your contribution under the CC0. See Public Domain Help Pages for more info.
PD
</div>
For MediaWiki's database table structure, see Manual:Database layout

Tables may be created in wiki pages. As a general rule, it is best to avoid using a table unless you need one. Table markup often complicates page editing.[1]

Wiki table markup summary[編集]

{| table start, required
|+ table caption, optional; only between table start and table row
|- table row, optional on first row—wiki engine assumes the first row
! table header cell, optional. Consecutive table header cells may be added on same line separated by double marks (!!) or start on new lines, each with its own single mark (!).
| table data cell, optional. Consecutive table data cells may be added on same line separated by double marks (||) or start on new lines, each with its own single mark (|).
|} table end, required
  • The above marks must start on a new line except the double || and !! for optionally adding consecutive cells to a line. However, blank spaces at the beginning of a line are ignored.
  • XHTML attributes. Each mark, except table end, optionally accepts one or more XHTML attributes. Attributes must be on the same line as the mark. Separate attributes from each other with a single space.
    • Cells and caption (| or ||, ! or !!, and |+) hold content. So separate any attributes from content with a single pipe (|). Cell content may follow on same line or on following lines.
    • Table and row marks ({| and |-) do not directly hold content. Do not add pipe (|) after their optional attributes. If you erroneously add a pipe after attributes for the table mark or row mark the parser will delete it and your final attribute if it was touching the erroneous pipe!
  • Content may (a) follow its cell mark on the same line after any optional XHTML attributes or (b) on lines below the cell mark. Content that uses wiki markup that itself needs to start on a new line, such as lists, headings, or nested tables, must be on its own new line.
    • Pipe character as content. To insert a pipe (|) character into a table, use the <nowiki>|</nowiki> escaping markup.

Basics[編集]

The following table lacks borders and good spacing but shows the simplest wiki markup table structure.

You type You get
{|
|Orange
|Apple
|-
|Bread
|Pie
|-
|Butter
|Ice cream 
|}
Orange Apple
Bread Pie
Butter Ice cream

The cells in the same row can be listed on one line separated by || (two pipe symbols). If the text in the cell should contain a line break, use <br /> instead.

You type You get
{|
|Orange||Apple||more
|-
|Bread||Pie||more
|-
|Butter||Ice<br />cream||and<br />more
|}
Orange Apple more
Bread Pie more
Butter Ice
cream
and
more

Extra spaces within cells in the wiki markup, as in the wiki markup below, do not affect the actual table rendering.

You type You get
{|
|  Orange || Apple || more
|-
|   Bread || Pie || more
|-
|   Butter || Ice cream || and more
|}
Orange Apple more
Bread Pie more
Butter Ice cream and more

You can have longer text or more complex wiki syntax inside table cells, too:

You type You get
{|
|Lorem ipsum dolor sit amet, 
consetetur sadipscing elitr, 
sed diam nonumy eirmod tempor invidunt
ut labore et dolore magna aliquyam erat, 
sed diam voluptua. 

At vero eos et accusam et justo duo dolores
et ea rebum. Stet clita kasd gubergren,
no sea takimata sanctus est Lorem ipsum
dolor sit amet. 
|
* Lorem ipsum dolor sit amet
* consetetur sadipscing elitr
* sed diam nonumy eirmod tempor invidunt
|}
Lorem ipsum dolor sit amet,

consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.

At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.

  • Lorem ipsum dolor sit amet
  • consetetur sadipscing elitr
  • sed diam nonumy eirmod tempor invidunt

Table headers[編集]

Table headers can be created by using "!" (exclamation mark) instead of "|" (pipe symbol). Headers usually show up bold and centered by default.

You type You get
{|
! style="text-align:left;"| Item
! Amount
! Cost
|-
|Orange
|10
|7.00
|-
|Bread
|4
|3.00
|-
|Butter
|1
|5.00
|-
!Total
|
|15.00
|}
Item Amount Cost
Orange 10 7.00
Bread 4 3.00
Butter 1 5.00
Total 15.00

Note: When using attributes as in the heading 'Item' a vertical bar '|' is used for separation. Not an exclamation character '!'.

Caption[編集]

A table caption can be added to the top of any table as follows.

You type You get
{|
|+Food complements
|-
|Orange
|Apple
|-
|Bread
|Pie
|-
|Butter
|Ice cream 
|}
Food complements
Orange Apple
Bread Pie
Butter Ice cream

class="wikitable"[編集]

Basic styling (light gray background, borders, padding and align left) can be achieved by adding class="wikitable".

You type You get
{| class="wikitable"
|+Food complements
|-
|Orange
|Apple
|-
|Bread
|Pie
|-
|Butter
|Ice cream 
|}
Food complements
Orange Apple
Bread Pie
Butter Ice cream

HTML colspan and rowspan[編集]

You can use HTML colspan and rowspan attributes on cells for advanced layout.

You type You get
{| class="wikitable"
!colspan="6"|Shopping List
|-
|rowspan="2"|Bread & Butter
|Pie
|Buns
|Danish
|colspan="2"|Croissant
|-
|Cheese
|colspan="2"|Ice cream
|Butter
|Yogurt
|}
Shopping List
Bread & Butter Pie Buns Danish Croissant
Cheese Ice cream Butter Yogurt

XHTML attributes[編集]

You can add XHTML attributes to tables. For the authoritative source on these, see the W3C's HTML Specification page on tables.

Attributes on tables[編集]

Placing attributes after the table start tag ({|) applies attributes to the entire table.

You type You get
{| class="wikitable" style="text-align: center; color: green;"
|Orange
|Apple
|12,333.00
|-
|Bread
|Pie
|500.00
|-
|Butter
|Ice cream
|1.00
|}
Orange Apple 12,333.00
Bread Pie 500.00
Butter Ice cream 1.00

Attributes on cells[編集]

You can put attributes on individual cells. For example, numbers may look better aligned right.

You type You get
{| class="wikitable"
| Orange
| Apple
| style="text-align:right;" | 12,333.00
|-
| Bread
| Pie
| style="text-align:right;" | 500.00
|-
| Butter
| Ice cream
| style="text-align:right;" | 1.00
|}
Orange Apple 12,333.00
Bread Pie 500.00
Butter Ice cream 1.00

You can also use cell attributes when you are listing multiple cells on a single line. Note that the cells are separated by ||, and within each cell the attribute(s) and value are separated by |.

You type You get
{| class="wikitable"
| Orange || Apple     || style="text-align:right;" | 12,333.00
|-
| Bread || Pie       || style="text-align:right;" | 500.00
|-
| Butter || Ice cream || style="text-align:right;" | 1.00
|}
Orange Apple 12,333.00
Bread Pie 500.00
Butter Ice cream 1.00

Attributes on rows[編集]

You can put attributes on individual rows, too.

You type You get
{| class="wikitable"
| Orange
| Apple
| style="text-align:right;"| 12,333.00
|-
| Bread
| Pie
| style="text-align:right;"| 500.00
|- style="font-style: italic; color: green;"
| Butter
| Ice cream
| style="text-align:right;"| 1.00
|}
Orange Apple 12,333.00
Bread Pie 500.00
Butter Ice cream 1.00

Simple one-pixel table border[編集]

An example of a one-pixel table border:

You type You get
{| border="1" style="border-collapse:collapse"
| Orange
| Apple
|-
| Bread
| Pie
|}
Orange Apple
Bread Pie

Border width[編集]

If "border-width:" has only one number, it is for all four border sides:

You type You get
{|style="border-style: solid; border-width: 20px"
|
Hello
|}

Hello

If "border-width:" has more than one number, the four numbers are for top, right, bottom, left (REMEMBER this order):

You type You get
{|style="border-style: solid; border-width: 10px 20px 100px 0"
|
Hello
|}

Hello

When there are fewer than 4 values, the value for left takes its default from the value for right, the value for bottom takes its default from the value for top, and the value for right takes its default from the value for top.

Another method to define the widths of the four sides of a cell is to use "border-left", "border-right", "border-top" and "border-bottom":

You type You get
{|style="border-left:solid 10px black;border-right:solid 20px black;border-top:solid 30px black;border-bottom:solid 40px black;" align="center" 
|
Hello
|}

Hello

Note Note:

  • The HTML attributes (such as "width=", "border=", "cellspacing=", "cellpadding=") do not need any length unit (the pixel unit is assumed). They are also invalid in HTML 5.

The CSS style properties (which override the HTML attributes) require an explicit length unit (if the value is not 0) such as "px" for the pixel.

With HTML attributes and CSS styles[編集]

CSS style attributes can be added with or without other HTML attributes.

You type You get
{| class="wikitable" style="color:green; background-color:#ffffcc;" cellpadding="10"
|Orange
|Apple
|-
|Bread
|Pie
|-
|Butter
|Ice cream 
|}
Orange Apple
Bread Pie
Butter Ice cream

Attributes[編集]

Attributes can be added to the caption and headers as follows.

You type You get
{| class="wikitable"
|+ style="caption-side:bottom; color:#e76700;"|''Food complements''
|-
|Orange
|Apple
|-
|Bread
|Pie
|-
|Butter
|Ice cream 
|}
Food complements
Orange Apple
Bread Pie
Butter Ice cream

Column width[編集]

Column width can be added as follows.

You type:

{| style="color: black; background-color: #ffffcc; width: 85%;"
| colspan="2" | This column width is 85% of the screen width (and has a background color)
|-
| style="width: 30%; background-color: white;"|
'''This column is 30% counted from 85% of the screen width'''
| style="width: 70%; background-color: orange;"|
'''This column is 70% counted from 85% of the screen width (and has a background color)'''
|}

You get:

This column width is 85% of the screen width (and has a background color)
This column is 30% counted from 85% of the screen width This column is 70% counted from 85% of the screen width (and has a background color)

Accessibility of table header cells[編集]

Table header cells do not explicitly specify which table data cells they apply to (those on their right on the same row, or those below them on the same column). When the table is rendered in a visual 2D environment, this is usually easy to infer.

However when tables are rendered on non-visual media, you can help the browser to determine which table header cell applies to the description of any selected cell (in order to repeat its content in some accessibility helper) using a scope="row" or scope="col" attribute on table header cells. In most cases with simple tables, you'll use scope="col" on all header cells of the first row, and scope="row" on the first cell of the following rows:

You type You get
{| class="wikitable"
|-
! scope="col"| Item
! scope="col"| Quantity
! scope="col"| Price
|-
! scope="row"| Bread
| 0.3 kg
| $0.65
|-
! scope="row"| Butter
| 0.125 kg
| $1.25
|-
! scope="row" colspan="2"| Total
| $1.90
|}
Item Quantity Price
Bread 0.3 kg $0.65
Butter 0.125 kg $1.25
Total $1.90

Alignment[編集]

Table alignment[編集]

Table alignment is achieved by using CSS. The table alignment is controlled by margins. A fixed margin on one side will make the table to be aligned to that side, if on the opposite side the margin is defined as auto. To have a table center aligned, you should set both margins to auto

For example, a right-aligned table:

You type You get
{| class="wikitable" style="margin-left: auto; margin-right: 0px;"
| Orange
| Apple
|-
| Bread
| Pie
|-
| Butter
| Ice cream 
|}
Orange Apple
Bread Pie
Butter Ice cream

And a center-aligned table:

You type You get
{| class="wikitable" style="margin: auto;"
| Orange
| Apple
|-
| Bread
| Pie
|-
| Butter
| Ice cream 
|}
Orange Apple
Bread Pie
Butter Ice cream

Table floating around text[編集]

If you align a table to the right or the left side of the page, the text that comes after the table starts at the end of it, leaving an empty space around the table. You can make the text to be wrapped around the table by making the table to float around the text instead of just aligning it. This can be achieved using the float CSS attribute, which can specify where the table floats to the right side or to the left. When using float, margins doesn't control table alignment and can be used to specify the margin between the table and the surrounding text.

You type You get
{| class="wikitable" style="float:right; margin-left: 10px;"
| Orange
| Apple
|-
| Bread
| Pie
|-
| Butter
| Ice cream 
|}

Lorem ipsum dolor sit amet, consectetuer adipiscing 
elit, sed diam nonummy nibh euismod tincidunt ut 
laoreet dolore magna aliquam erat volutpat. Ut wisi 
enim ad minim veniam, quis nostrud exerci tation 
ullamcorper suscipit lobortis nisl ut aliquip ex ea 
commodo consequat. Duis autem vel eum iriure dolor 
in hendrerit in vulputate velit esse molestie consequat, 
vel illum dolore eu feugiat nulla facilisis at vero 
eros et accumsan et iusto odio dignissim qui blandit 
praesent luptatum zzril delenit augue duis dolore te 
feugait nulla facilisi.
Orange Apple
Bread Pie
Butter Ice cream

Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.

Cell contents alignment[編集]

The alignment of cell contents can be controlled with 2 different CSS properties: text-align and vertical-align. text-align can be specified at the table, row or individual cells, while vertical-align only can be specified at individual rows or cells.

You type You get
{| class="wikitable"
|- style="vertical-align:top;"
| style="height:100px; width:100px; text-align:left;" | A
| style="height:100px; width:100px; text-align:center;" | B
| style="height:100px; width:100px; text-align:right;" | C
|- style="vertical-align:middle;"
| style="height:100px; width:100px; text-align:left;" | D
| style="height:100px; width:100px; text-align:center;" | E
| style="height:100px; width:100px; text-align:right;" | F
|- style="vertical-align:bottom;"
| style="height:100px; width:100px; text-align:left;" | G
| style="height:100px; width:100px; text-align:center;" | H
| style="height:100px; width:100px; text-align:right;" | I
|}
A B C
D E F
G H I

Caveats[編集]

Negative numbers[編集]

If you start a cell on a new line with a negative number with a minus sign (or a parameter that evaluates to a negative number), your table can get broken, because the characters |- will be parsed as the wiki markup for table row, not table cell. To avoid this, insert a space before the value (| -6) or use in-line cell markup (|| -6).

CSS vs attributes[編集]

Table borders specified through CSS rather than the border attribute will render incorrectly in a small subset of text browsers.

Common attributes for columns, column groups and row groups[編集]

The MediaWiki syntax for tables currently offers no support for specifying common attributes for columns (with the HTML element <col />), column groups (HTML element <colgroup></colgroup>) and row groups (HTML elements <thead></thead>, <tbody></tbody><code> and <code><tfoot></tfoot>). Those standard HTML elements are not accepted even in their HTML or XHTML syntax.

All the rows and cells (header or data) of the table are rendered within a single implicit row group (HTML element <tbody></tbody>) without any attributes or styles.

See also[編集]

Notes[編集]

  1. Tables can be created using either XHTML table elements directly, or using wikicode formatting to define the table. XHTML table elements and their use are well described on various web pages and will not be discussed here. The benefit of wikicode is that the table is constructed of character symbols which tend to make it easier to perceive the table structure in the article editing view compared to XHTML table elements.

案内メニュー