You are reading: Wikiafripedia, the free encyclopedia that you can monetize your contributions with ads
All Wikipedia Editorial rules applies here + you are free to place ads on articles you authored on Wikiafripedia and earn revenue based on the number of people that read your article daily - imagine if Wikipedia was like that.
Right now, the most read article on Wikiafripedia is SSSniperwolf
If you need help getting started, WhatsApp Shusmitha on: +2348032569168
You are reading: Wikiafripedia, the free encyclopedia that you can monetize your contributions with ads
All Wikipedia Editorial rules applies here + you are free to place ads on articles you authored on Wikiafripedia and earn revenue based on the number of people that read your article daily - imagine if Wikipedia was like that.
Right now, the most read article on Wikiafripedia is SSSniperwolf
If you need help getting started, WhatsApp Shusmitha on: +2348032569168

Help:Table

From Wikiafripedia, the free encyclopedia that you can monetize your contributions or browse at zero-rating.
Jump to navigation Jump to search

A table is an arrangement of columns and rows that organizes and positions data. Tables can be created on Wikiafripedia pages using special wikitext syntax, and many different styles and tricks can be used to customise them.

Tables can be used as formatting instrument, but consider using a multi column list instead.

Using the toolbar[edit source | edit]

Vector toolbar – default
Monobook toolbar

To automatically insert a table, click Vector toolbar insert table button.png or Button insert table.png (Insert a table) on the edit toolbar. If "Insert a table" is not on the toolbar follow these directions to add it.

The following text is inserted when Insert a table is clicked:

{| 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
|}

This code produces the following table:

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

The sample text ("Header N" or "row N, cell N") is intended to be replaced with actual data.

Basic table markup summary[edit source | edit]

{|

Table start

Required.
|+

Table caption

Optional.

Only between table start and first table row.

|-

Table row

Optional.

Can be omitted before 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 (|). This mark is also used to separate HTML attributes from cell and caption contents.

|}

Table end

Required.
  • The above marks must start on a new line, except the double marks (|| and !!) for optionally adding consecutive cells to a single line.
  • Blank spaces at the beginning of a line are ignored.
  • Content may either follow its cell mark on the same line (after any optional HTML attributes); or on lines below the cell mark. Content that uses wiki markup that itself needs to start on a new line, such as with lists, headings, or nested tables, must be on its own new line.
  • To insert a pipe character (|) into a table caption or cell, use the <nowiki>|</nowiki> escaping markup.

HTML attributes[edit source | edit]

Each mark, except table end (|}), optionally accepts one or more attributes. Attributes must be on the same line as the mark.

  • Cells and captions (| or ||, ! or !!, and |+) hold content— separate any attribute from its content with a single pipe (|), with attributes preceding content.
  • Table and row marks ({| and |-) do not directly hold content. Do not add a pipe (|) after any attributes.

Commonly included attributes in tables include: class, for example class="wikitable"; style, for CSS styling; scope, to indicate row or column header cells; rowspan, to extend cells by more than one row; colspan, to extend cells by more than one column; and border, for borders for non-wikitable tables.

Pipe syntax tutorial[edit source | edit]

Although HTML table syntax also works, special wikicode can be used as a shortcut to create a table. The vertical bar or "pipe" symbol ( | ) codes function exactly the same as HTML table markup, so a knowledge of HTML table code helps understand pipe code. The shortcuts are as follows:

  • The entire table is encased with curly brackets and a vertical bar character (a pipe). So use {| to begin a table, and |} to end it. Each one needs to be on its own line:
{|
  table code goes here
|}
  • An optional table caption is included with a line starting with a vertical bar and plus sign "|+" and the caption after it:
{|
|+ caption
  table code goes here
|}
  • To start a new table row, type a vertical bar and a hyphen on its own line: "|-". The codes for the cells in that row start on the next line.
{|
|+ The table's caption
|-
  row code goes here
|-
  next row code goes here
|}
  • Type the codes for each table cell in the next row, starting with a bar:
{|
|+ The table's caption
|-
| cell code goes here
|-
| next row cell code goes here
| next cell code goes here
|}
  • Cells can be separated with either a new line and a single bar, a new line and a double bar, or by a double bar "||" on the same line. All three produce the same output:
{|
|+ The table's caption
|-
|Cell 1 || Cell 2 || Cell 3
|-
|Cell A
|Cell B
|Cell C
|}
  • A row of column headers 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. The scope="col" markup is not technically necessary in wikitables styled with class markup: class="wikitable" and so on. However, it is easier for other editors to understand the markup when it is present, and the Manual of Style recommends using it because it directly associates header with corresponding cells, a boon to accessibility.
{|
|+ The table's caption
! scope="col" | Column header 1
! scope="col" | Column header 2
! scope="col" | Column header 3
|-
| Cell 1 || Cell 2 || Cell 3
|-
| Cell A
| Cell B
| Cell C
|}
  • The first cell of a row is identified as a row header by starting the line with "! scope="row" |" instead of "|", and starting subsequent data cells on a new line. The scope="row" code, as with scope="col", is not technically required in wikitables styled with class markup like class="wikitable", but it is recommended by the Manual of Style for both accessibility and code readability reasons.
{|
|+ The table's caption
! scope="col" | Column header 1
! scope="col" | Column header 2
! scope="col" | Column header 3
|-
! scope="row" | Row header 1
| Cell 2 || Cell 3
|-
! scope="row" | Row header A
| Cell B
| Cell C
|}
  • The final table displays like this:
The table's caption
Column header 1 Column header 2 Column header 3
Row header 1 Cell 2 Cell 3
Row header A Cell B Cell C
  • Optional parameters can modify the display and styling of cells, rows, or the entire table. The simplest way to add styling is to set the wikitable CSS class, which in Wikiafripedia's external style sheet is defined to apply a gray color scheme and cell borders to tables using it:
{| class="wikitable"
|+ The table's caption
! Column header 1
! Column header 2
! Column header 3
|-
! scope=row | Row header 1
| Cell 2 || Cell 3
|-
! scope=row | Row header A
| Cell B
| Cell C
|}


Which produces this:

The table's caption
Column header 1 Column header 2 Column header 3
Row header 1 Cell 2 Cell 3
Row header A Cell B Cell C

The table parameters and cell parameters are the same as in HTML, see http://www.w3.org/TR/html401/struct/tables.html#edef-TABLE and Table (HTML). However, the thead, tbody, tfoot, colgroup, and col elements are currently not supported in MediaWiki, as of April 2017. If row headers are used, it is good practice to label them as such using scope=row.

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 &nbsp; as content to ensure that the cells are displayed.

With colspan and rowspan cells can span several columns or rows;