Help:Other Table Formats

From MobileRead
Jump to: navigation, search

Contents

[edit] Other table syntax

Other types of table syntax that MediaWiki supports:

  1. XHTML
  2. HTML & wiki-<td> syntax (Do not use)

All three are supported by MediaWiki and create (currently) valid HTML output, but the pipe syntax is the simplest. Also, HTML & wiki-<td> syntax (i.e., unclosed <td> and <tr> tags) will not necessarily remain browser-supported in the upcoming future, especially on handheld internet-accessible devices.

See also Help:Table Editing. Note that some HTML elements such as the thead, tbody, tfoot, colgroup, and col elements are currently not supported in W:MediaWiki.

[edit] Comparison of table syntax

 XHTML HTML & Wiki-td Wiki-pipe
Table <table></table> <table></table>
{|
|}
Caption <caption>caption</caption> <caption>caption</caption>
|+ caption
Row <tr></tr> <tr>
|-
Data cell

<td>cell1</td>
<td>cell2</td>

<td>cell1
<td>cell2

| cell1
| cell2
Data cell <td>cell1</td> <td>cell2</td> <td>cell3</td> <td>cell1 <td>cell2 <td>cell3
| cell1 || cell2 || cell3
Header cell <th>heading</th> <th>heading
! heading
Sample table
1 2
3 4
<table>
   <tr>
      <td>1</td>
      <td>2</td>
   </tr> 
   <tr>
      <td>3</td> 
      <td>4</td> 
   </tr>
</table>
<table>
   <tr>
      <td> 1 <td> 2
   <tr>
      <td> 3 <td> 4
</table>
{| 
| 1 || 2
|- 
| 3 || 4
|}
Sample table
1 2
3 4
5 6
<table>
   <tr>
      <td>1</td>
      <td>2</td>
   </tr> 
   <tr>
      <td>3</td>
      <td>4</td>
   </tr>
   <tr>
      <td>5</td>
      <td>6</td>
   </tr>
</table>
<table>
   <tr>
      <td> 1 <td> 2
   <tr>
      <td> 3 <td> 4
   <tr>
      <td> 5 <td> 6
</table>
{| 
| 1 || 2 
|- 
| 3 || 4 
|- 
| 5 || 6 
|}
Pros
  • Can be previewed/debugged with any XHTML editor
  • Can be formatted for easier reading
  • Well-known
  • Insensitive to newlines
  • No characters like "|" which can collide with template and parser function syntax
  • Can be previewed/debugged with any HTML editor
  • Can be formatted for easier reading
  • Well-known
  • Takes less space than XHTML
  • Insensitive to newlines
  • No characters like "|" which can collide with template and parser function syntax
  • Easy to write
  • Easy to read
  • Takes little space
Cons
  • Tedious
  • Takes a lot of space
  • Difficult to read quickly
  • May not have browser support in future
  • Unfamiliar syntax
  • Rigid structure
  • Cannot be indented
  • Text (as in HTML tags) may be easier for some people to read than series of pipes, plus signs, exclamation marks, etc.
  • Is nothing more than a shortcut for HTML-style tags. Not easily understood by those unfamiliar with HTML table concepts
  • Assigning to a template parameter a value containing "|" requires Template:!
  • Sensitive to newlines; since these are automatically stripped from templates and parameters in some cases, special techniques are sometimes needed to avoid this, see Help:Newlines and spaces
 XHTML HTML & Wiki-td Wiki-pipe

See also Template talk:For#Tables.

[edit] Pipe syntax in terms of the HTML produced

The pipe syntax, developed by Magnus Manske, substitutes pipes (|) for HTML. There is an on-line script which converts html tables to pipe syntax tables.

The pipes must start at the beginning of a new line, except when separating parameters from content or when using || to separate cells on a single line. The parameters are optional.

[edit] Tables

A table is defined by {| ''params'' |} which equals <table ''params''>Insert non-formatted text here </table>

[edit] Rows

<tr> tags will be generated automatically for the first row. To start a new row, use

|-

which results in

<tr>

Parameters can be added like this:

|- params

which results in

<tr params>

Note:

  • <tr> tags will be automatically opened at the first <td> equivalent
  • <tr> tags will be automatically closed at <tr> and </table> equivalents

[edit] Cells

Cells are generated either like this:

|cell1
|cell2
|cell3

or like this:

|cell1||cell2||cell3

which both equal

<td>cell1</td><td>cell2</td><td>cell3</td>

so "||" equals "newline" + "|"

Parameters in cells can be used like this:

|params|cell1||params|cell2||params|cell3

which will result in

<td params>cell1</td>
<td params>cell2</td>
<td params>cell3</td>

[edit] Headers

Functions the same way as TD, except "!" is used instead of the opening "|". "!!" can be used instead of "||". Parameters still use "|", though! Example:

!params|cell1

[edit] Captions

A <caption> tag is created by

|+ Caption

which generates

<caption>Caption</caption>

You can also use parameters:

|+ params|Caption

which will generate

<caption params>Caption</caption>
Personal tools
Namespaces

Variants
Actions
Navigation
MobileRead Networks
Toolbox