Différences entre versions de « Help/Tables »

De Rich Annotator System
m (A protégé « Help/Tables » ([Modifier=Autoriser uniquement les administrateurs] (infini) [Renommer=Autoriser uniquement les administrateurs] (infini)))
 
(Une version intermédiaire par le même utilisateur non affichée)
Ligne 1 : Ligne 1 :
 +
__NOTOC__
 
'''Tables''' may be created. As a general rule, it is best to avoid using a table unless you need one. Table markup often complicates page editing.
 
'''Tables''' may be created. As a general rule, it is best to avoid using a table unless you need one. Table markup often complicates page editing.
  
Ligne 96 : Ligne 97 :
  
 
'''Attributes on rows, caption and headers'''<br>
 
'''Attributes on rows, caption and headers'''<br>
You can put attributes on individual '''rows''', too, and attributes can be added to the caption and headers.
+
You can put attributes on individual rows, too, and attributes can be added to the caption and headers.
  
 
'''Column width'''<br>
 
'''Column width'''<br>
Ligne 118 : Ligne 119 :
 
|}
 
|}
  
 
+
====Tables and the VisualEditor (VE)====
 +
See [[Help/Formatting#VisualEditor|Visual Editor]].
  
  

Version actuelle datée du 26 octobre 2020 à 10:26

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

Wiki table markup summary

{| table start, required
|+ table caption, optional; only between table start and table row
|- table row, optional on first row (first row is assumed)
! 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.
  • HTML attributes. Each mark, except table end, optionally accepts one or more HTML 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 HTML 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

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

You can use HTML colspan and rowspan attributes on cells for advanced layout: !colspan="6"|Shopping List, |rowspan="2"|Bread.

HTML attributes

You can add HTML attributes to tables. For the authoritative source on HTML attributes, 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: {| class="wikitable" style="text-align:center; color:green;".

Attributes on cells
You can put attributes on individual cells. For example, numbers may look better aligned right: | style="text-align:right;" | 12.

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 |.

Attributes on rows, caption and headers
You can put attributes on individual rows, too, and attributes can be added to the caption and headers.

Column width
Column width can be added as follows.

You type:

{| class="wikitable" style="width: 85%;"
| colspan="2" | This column width is 85% of the screen width
|-
| style="width: 30%"| '''This column is 30% counted from 85% of the screen width'''
| style="width: 70%"| '''This column is 70% counted from 85% of the screen width'''
|}

You get:

This column width is 85% of the screen width
This column is 30% counted from 85% of the screen width This column is 70% counted from 85% of the screen width

Tables and the VisualEditor (VE)

See Visual Editor.


Back to contents