You can use the Mediawiki edit toolbar to create tables on Wikipedia, and some Wikimedia projects. It is helpful to generate the necessary codings. However, on many MediaWiki wikis (and by default) the table tool is not available.

Use the first button on the right of the toolbar to insert a table when editing a page.

a row of column headings is identified by using "!" instead of "|", and using "!!" instead of "||". Header cells typically render differently from regular cells, depending on the browser. They are often rendered in a bold font and centered.

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 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. To show a visible pipe in a cell, use <nowiki>|</nowiki> or &#124;.

With colspan and rowspan cells can span several columns or rows, see the Mélange example below. However, this has the disadvantage that sorting does not work properly anymore.

The width and height of the whole table can be specified, as well as the height of a row. To specify the width of a column one can specify the width of an arbitrary cell in it. If the width is not specified for all columns, and/or the height is not specified for all rows, then there is some ambiguity, and the result depends on the browser.

If you wish to force column widths to your own requirements, rather than accepting the width of the widest text element in a column's cells, then follow this example. Note that wrap-around of text is forced.

To fix this, apply the valign="top" attribute to the rows. Alternatively use style="vertical-align:top;". (Unfortunately it seems to be necessary to apply this individually to every single row. Thats why you can try class="toptextcells" or class="wikitable sortable toptextcells".) For example:

Here's a more advanced example, showing some more options available for making up tables. Note, however, that with use of the colspan and rowspan attributes, sorting does not work properly any more.

You can play with these settings in your own table to see what effect they have. Not all of these techniques may be appropriate in all cases; just because you can add colored backgrounds, for example, doesn't mean it's always a good idea. Try to keep the markup in your tables relatively simple -- remember, other people are going to be editing the article too! This example should give you an idea of what is possible, though.

Five different (blue) tables are shown nested inside the cells of a table. Automatically the two tables |A| and |B|B| are vertically aligned instead of the usual side by side of text characters in a cell. "float" is used to fix each of tables |C| and |D| to their own position within one cell of the table. This may be used for charts and schemes. Nested tables must start on a new line.

Note that using rowspan="2" for cell G combined with rowspan="3" for cell F to get another row below G and F won't work, because all (implicit) cells would be empty. Likewise complete columns are not displayed if all their cells are empty. Borders between non-empty and empty cells might be also not displayed (depending on the browser), use &nbsp; to fill an empty cell with dummy content.

At the start of a cell, add your parameter followed by a single pipe. For example width="300"| will set that cell to a width of 300 pixels. To set more than one parameter, leave a space between each one.

A simple and reliable way to achieve decimal point alignment is to use Template:0, assuming it has been defined along the following lines: <span style="visibility:hidden;color:transparent;">{{{1|0}}}</span>

If the column of numbers appears in a table with cell padding or cell spacing, one can still align the decimal points without an unsightly gap in the middle. Embed a table in each number's cell and specify its column widths. Make the embedded tables' column widths the same for each cell in the column. (If decimal points are still misaligned using this method, the main table's column may be too narrow. Add a parameter to increase the column's width.)

individually, but jointly for tables of the class concerned on all web pages, on the local computer of the user.

Instead of remembering table parameters, you just include an appropriate style class after the {|. This helps keep table formatting consistent, and can allow a single change to the class to fix a problem or enhance the look of all the tables that are using it at once. For instance, this:

simply by replacing inline CSS for the table by class="wikitable". This is because the wikitable class in MediaWiki:Common.css and the "../skins/common/shared.css" file contain a number of table.wikitableCSS style rules. These are all applied at once when you mark a table with the class. You can then add additional style rules if desired. These override the class's rules, allowing you to use the class style as a base and build up on it:

Notice that the table retains the gray background of the wikitable class, and the headers are still bold and centered. But now the text formatting has been overridden by the local style statement; all of the text in the table has been made italic and 120% normal size, and the wikitable border has been replaced by the red dashed border.

Of course this works only for browsers supporting inline CSS, if it's important use XHTML markup like <big> instead of "font-size:120%", or Wiki markup like ''text'' instead of "font-style:italic".

Tables can be made sortable by adding class="sortable"; for details see Help:Sorting. Since this can be very useful, it is wise to keep the possibilities and limitations of this feature in mind when designing a table. For example:

Do not divide a table into sections by subheaders spanning several rows. Instead, an extra column can be made showing the content of these headers on each row, in a short form.

Do not have elements spanning several columns; instead, again, repeat the content on each row, in a short form.

In a column of numbers, do not put text such as "ca." in front of a number—it will sort like zero. Do not put text after the number, and do not put a range of numbers (it does not affect the sorting position for numeric sorting mode, and in the case of a range, the first number determines the position, but if, possibly after sorting this or another column, the element is at the top, it will induce alphabetic sorting mode). Instead, put these texts in a separate column. Alternatively, for the greatest flexibility, alphabetic sorting mode with hidden sortkeys can be used.

A long form of abbreviated content can be put as legend outside the table.

Regardless of whether wikitable format or HTML is used, the wikitext of the rows within a table, and sometimes even within a collection of tables, has much in common, e.g.:

the basic code for a table row

code for color, alignment, and sorting mode

fixed texts such as units

special formats for sorting

In that case it can be useful to create a template that produces the syntax for a table row, with the data as parameters. This can have many advantages:

easily changing the order of columns, or removing a column

easily adding a new column if many elements of the new column are left blank (if the column is inserted and the existing fields are unnamed, use a named parameter for the new field to avoid adding blank parameter values to many template calls)

computing fields from other fields, e.g. population density from population and area

duplicating content and providing span tags with "display:none" for the purpose of having one format for sorting and another for display

easy specification of a format for a whole column, such as color and alignment

When producing table syntax using templates and/or parser functions, a pipe character in a parameter has to be coded {{!}}, which uses Template:!, to avoid being interpreted as parameter separator for the template or parser function. see Template:Table example with optional row.

In the case of a conditional table row we typically need code of the form "{{!}}-newline{{!}}.. newline" as then- or else-part of an if-construct. To avoid trimming, use a branching template (in this example Template:Ifnotempty) that preserves the newline:

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.

Tables using HTML syntax can have pieces in templates only if the variable $wgUseTidy has been set, as is the case in most Wikimedia projects.

In most cases, when a code line is longer than the web browser window's width, then a scrolling bar appears at bottom, to let the viewer slide to the right side (and also left side) to see the rest of the codes, because, the use of <pre> tag causes the code line to remain intact, unless an EOL (CR/LF) hidden character is reached in that text line. But having to slide or scroll to the right or left for viewing the full codes is often not comfortable to many readers. To solve such problem, using the <p>, <tt> and <br /> HTML tags, are better than using the <pre> tag, as those will limit the length of a line of code according the available space in the web browser's window and therefore will not result in the need to move the scroll-bar right (or left) for viewing. By placing the codes inside the <tt>...</tt> HTML tags, codes are displayed with a fixed width text/font, (like the <pre> tag uses) for easier reading. HTML tag <br /> is used to display (or bring) next line of codes, starting from the next line. HTML tag <p> along with its CSS style properties, is used to create the blue colored dashed bordered rectangular box (Code box) around the codes, (like the HTML <pre> tag, which gets these properties from the main.css stylesheet file).

Code box above the table has the auto line wrapping feature enabled. Note the long line (the sixth line from top) inside the codes, which is wrapped inside the Code box. This Code box and the codes, can be displayed by using below codes in the edit box.

See the above codes, note that, <nowiki>...</nowiki> tags were used to disable wiki markup codes for beginning a table ({|), ending a table (|}), start of an image displaying ([[), or a hyperlink, etc. All wiki & HTML markup codes need to be disabled by enclosing them inside the <nowiki>...</nowiki> tags. If these codes were to be displayed inside another table, then, each | (pipe) & ! (Exclamation mark) symbol also needed to be enclosed inside the <nowiki> tags. Note that, the longer line is automatically wrapped according to the width of the web browser's window, inside the Code box.

Alternatively, we can replace each | (pipe symbol) character with &#124; (HTML decimal entity code), replace each ! (exclamation mark) with &#33; code, replace { (beginning curly/second bracket) with &#123; and we may replace } (closing curly/second bracket) with &#125; code. Also replace the < (less than sign, or beginning angle bracket) with &#60; numeric entity code or, replace it with &lt; (HTML symbol entity code). For more on HTML decimal or hexadecimal numeric entity codes, please see w:Windows Alt codes. To display the wiki image markup code, we should replace the [ (beginning square/third bracket) with &#91; and we may replace ] (closing square/third bracket) with &#93;. When we are replacing characters with their numeric enitity codes, we are actually disabling their normal functionality, so we can display them on the web page(s).

By using the numeric entity codes, mentioned in the above paragraph, below codes can display the above Code box in another alternative (better) way. Note that, the longer line is automatically wrapped, without exceeding the browser window's width, inside the below Code box.

Another alternative is to display the source code within a <source code="html5">...</source> element (with the additional benefit of keeping HTML comments visible, and coloring the HTML compatible syntax, even if the wiki-specific syntax itself is not colorized where it uses specific delimiters, like [paired brackets] for links, {paired braces} for templates transclusion or parameters and tables, pipes between template parameters, pipes and exclamation marks between table cells in the same row, __MAGIC__ keywords, and the specially recognized punctuation at start of lines for lists, indented blocks; preformated text and section headings ; it also preserves source code indentation with whitespaces).

In that case you can easily format the source code for reasonnably short lines, simply by manually inserting newlines and reasonnable indentation, without modifying the source wiki code inserted directly in the source element. Embedding wiki code in a source element is then interesting to use instead of embedding it in a pre element, whose rendering is more difficult to read for complex wiki code. That way the source code will render as follows:

Note also that HTML named or numeric character entities (such as &nbsp; or &#32;) that are present in the embedded source code will not be substituted by the character they represent, but will be rendered verbatim (and colorized specifically).

But note that opening and closing includeonly/noinclude/includeonly tags that are present within the source code embedded in a <source code="html5">...</source> element are still recognized by MediaWiki, and may cause parts of the code not being rendered; the only way to escape these tags is to alter them in the source by inserting some control (such as a zero-width space or word joiner) before or in the middle of their tag name.

To format for a square monitor or window, use a tape measure. Determine the height of your rectangular screen. Using that figure measure under the screen to determine the width your monitor’s screen would be if it were square. Mark that location using ink or tape under the screen. Drag the side of your browser’s window to that location so the window is square based on accurate measurements. Square monitors and reading windows are not able to contain tables and galleries made for rectangular and wide screens. When a table or gallery is wider than the monitor, it makes every line of text wider than the screen as well. The px amounts of the following gallery were determined after measuring the window to make sure it was square:

Tables are an essential part of presenting information in an easily understandable way. Everything on Wikipedia can be copied elsewhere, and it is encouraged. But Wikipedia tables oftentimes lose their borders when pasted into web pages, blogs, or email.

The Wikipedia table button produces this:

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

Note the borders around all the cells, and the whole table. Copy and paste the table into your email, and the borders disappear. This makes the table look something like this below. It is much less understandable.

The table will look the same on the Wikipedia page, but it will now also have borders when copied into email, blogs, and other web pages. Bloggers and webmasters will not have to add CSS code in order to see the chart in a format with basic borders.