Help:Table

A table is an arrangement of columns and rows that organizes and positions data or images. Tables can be created on Wikipedia 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.

In source mode




To automatically insert a table, click or  (Insert a table) on the edit toolbar. In the Vector toolbar the table icon is in the "Advanced" menu. 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:

This code produces the following table:

The sample text ("Header text" or "Example") is intended to be replaced with actual data. You can fill in the table while in source mode. Or use the Visual Editor (VE).

In Visual Editor
With the Visual Editor (VE) you directly fill in the cells without having to go through wikitext. See the VE section farther down. VE makes it easy to add or delete rows or columns. In VE this is what shows up when clicking the table icon (in the "Insert" menu):

Basic table markup summary

 * 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 (beware of undesired paragraphs though). 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   escaping markup.

HTML attributes
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:, for example  ;  , for CSS styling;  , to indicate row or column header cells;  , to extend cells by more than one row;  , to extend cells by more than one column.

Pipe syntax tutorial
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:  {|    table code goes here  |} 
 * 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:
 * An optional table caption is included with a line starting with a vertical bar and plus sign " " and the caption after it:
 * 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.
 * Type the codes for each table cell in the next row, starting with a bar:
 * Cells can be separated with either a new line and a single bar, or by a double bar " " on the same line. Both produce the same output:

Wiki source

Rendered result


 * 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  CSS class, which in Wikipedia's external style sheet is defined to apply a gray color scheme and cell borders to tables using it:

Wiki source

Rendered result

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, , , , and elements are currently not supported in MediaWiki,.

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 zero width space &#x200B; or older non-breaking space html as content to ensure that the cells are displayed.

With  and   cells can span several columns or rows;

Rendering the pipe
When cell content that contains a pipe character does not render correctly, simply add an empty format for that cell. The second pipe character in a line of  will not display; it is reserved for adding a format. Wikicode between the first and second pipe is a format, but since emptiness or an error there is ignored, it just disappears. When this happens, add a dummy format. Use a third pipe character to render your first pipe character.

Rendering the first pipe when it is the third pipe in the cell code.

Wiki source

Rendered result

The third and later pipe characters will render, but to display two adjacent pipe characters in a cell, (instead of having them act as the first pipe at the start of a new cell), other pipe-rendering options are needed. Instead of using a dummy format to render a pipe, you can render it directly by 1)  (preferred) or 2) html:   or. Each line of cell code in the following table has one wikicode pipe.

Displaying adjacent pipes

Wiki source

Rendered result

Template !, because of the order in which things are parsed, is equivalent to typing in a single | pipe character. The single  parser-tag does not apply here. See how they do not escape the second pipe, as &amp;#124 and  did above:

Common mechanisms that do not work in tables

Wiki source

Rendered result

Scope
Column headers are identified by  instead of. Row headers are identified by  instead of. Each header cell should be on a separate line in the wiki-markup. The  and   markup should be used for column and row headers in all data tables because it explicitly associates the header with the corresponding cells, which helps ensure a consistent experience for screen readers. The Manual of Style requires the use of scope for column and row headers.

For complex tables, when a header spans two columns or rows, use  or   respectively to clearly identify the header as a column header of two columns or a row header of two rows. When headers are unclear, this can cause accessibility issues; therefore, use  to set a unique value without spaces on each header, then reference the id(s) on the data cells that have unclear headers using   with a space separating each id.

Header cells typically render differently from regular cells, depending on the browser. They are often rendered in a bold font and centered. If this rendering is not desired from an aesthetic point of view, the table can be styled with the "plainrowheaders" class which left-aligns the row headers and removes the bolding.

A typical example may be marked up like this:

Wiki source

Rendered result

Row headers
Note that with row headers you need to use a separate row in the wikitext for the row header cell. See the correct format in the last table in the previous section. Note the use of single and double pipes (bars).

Here below is what the table looks like if the data cell wikitext is on the same line as the row header wikitext. Note that the data cell backgrounds are the same shade of gray as the column and row headers. Data cells should have a lighter background.

Wiki source

Rendered result

If you have a long wiki table in the above format and want to quickly make the data cell backgrounds lighter, then use tab2wiki. Copy the table right off the page (not the wikitext) and paste it into tab2wiki. Check the following boxes: Uncheck this: Check or uncheck "sortable table" depending on your needs. Then click "Do it". Copy the wikitext results back to the wiki. You must use  to get the background shading.
 * First element in a column is a header
 * First element in a row is a header
 * Compress table

Tab2wiki fixes the problem by using the long table format in the wikitext. Note that only single bars (pipes) are used below.

The row header cells are on separate lines in the wikitext. You will have to add back the scopes to make  work, and get non-bolded row header text.

Wiki source

Rendered result

Another way to fix the problem is to copy the table wikitext to a text editor such as freeware NoteTab Light. The following method works for tables with flag templates. In the table wikitext do a mass replace of
 * }}||

with
 * }}^P|

^P is the NoteTab Light code for a line break. That puts the row header cells on a separate line in the wikitext. And you don't lose your templates or styling. And you maintain most of the compressed wikitext format.

Minimalist table
Both of these generate the same output. Choose a style based on the number of cells in each row and the total text inside each cell.

Wiki source

Rendered result (note that there are no borders).

Multiplication table
Note that in this example  is used to style the table with Wikipedia's external style sheet for tables. It adds borders, background shading, and bold header text.

Wiki source

Rendered result

Captions and summaries
Explicit table captions are recommended for data tables as a best practice; the Wikipedia Manual of Style considers them a high priority for accessibility reasons, as a caption is explicitly associated with the table, unlike a normal wikitext heading or introductory sentence. All data tables on Wikipedia require captions. A caption is provided with the  markup, similar to a table row, but it does not contain any cells, and is not within the table border. Captions are always displayed, appearing as a title centered (in most browsers), above the table. A caption can be styled (with inline, not block, CSS), and may include wikilinks, reference citations, etc.

A provides an overview of the data of a table for text and audio browsers, and does not normally display in graphical browsers. The summary (also a high Manual of Style priority for tables) is a synopsis of content, and does not repeat the caption text; think of it as analogous to an image's  description. A summary is added with, on the same line as the   that opened the table, along with any   and other parameters for the table as a whole. The  attribute is, however, obsolete in HTML5.

Wiki markup example showing left-aligned caption with a source citation:

Rendered result

Width

 * Note:  is obsolete in HTML 5, and so it could eventually be ignored by MediaWiki. See:  HTML 5. Use CSS style instead:  

  can be used in the top line of a table's wikitext to specify the maximum width of the table as a whole. For some tables this is all that is needed.

The following table excerpt is from this version of List of countries by wealth per adult. The goal is to narrow the data columns, and have the country names spread out on one line each. All of this makes it easier when scanning down a country list. But the country names have to wordwrap if needed (in narrow portrait views on some cell phones, etc.). So   was used in selected column heads. Here is the relevant header wikitext:

Here below is what it looks like without   Narrow your browser window to see how the table below contracts versus the one above. The table above maintains one line per country for narrower browser and screen widths, and is therefore more readable in long country tables. The table format below can greatly increase in number of lines, and require more vertical scrolling.

Em units are good because they increase in size along with the zoom setting. Max-width is better than using breaks  in headers, because header breaks annoy people using screen readers due to the pauses. Max-width also allows tables to shrink to fit in smaller tablet and phone screens.

  does not narrow further in any circumstance, and so its use should be avoided. See why on this subpage. For the same reason  should be avoided.

Height
The height of the whole table can be specified, as well as the height of a row. The height of the middle row below is set to  and the total height of the whole table is set to   units. Doing the math shows that the height of the top and bottom rows are 3.5 em units each. 3.5 + 3.5 + 7 = 14. If there is wordwrap then the height will increase to accommodate this.

Wiki markup

Rendered result

Setting borders
Add a border around a table using the CSS property, for example. This example uses a solid (non-dashed) gray border that is one pixel wide:

Wiki source

Rendered result Note the bottom-row texts are centered by  while the star images are not centered (i.e. left aligned).

As long as the  specs omit the parameter   they don't show the caption lines in the table (only during mouse-over). The border color  matches typical tables or infoboxes in articles; however, it could be any color name (as in  ) or use a hex-color (such as:  ).

Borders of every cell in a table
Wiki source

Rendered result

If all cells have the same border color, the resulting double borders may not be wanted; add the  CSS property on the table opening tag to reduce them to single ones (  is obsolete).

Additionally, the W3C allows the use of the otherwise obsolete  attribute on the table root  if its value is "1". This adds a one-pixel border, in the default color, to the table and all of its cells at once:

Using the  property to combine the double borders, as described above:

Wiki source

Rendered result

Side by side tables
You can place two or more tables side by side. But the tables must wrap (one dropping below the other) in narrow screens if horizontal scrolling is to be avoided. Here is the relevant wikitext below. More info here.

Note that the space between the tables happens because  is on a line by itself. If you want no space use this:

Narrow your browser window to see the tables below wrap. This works in mobile view too. Click on "mobile view" at the bottom of any Wikipedia page.

These tables are adapted excerpts from versions of Iceland men's national handball team. Many sport articles have side by side tables.

can not be added within the table wikitext. It must be added outside the table wikitext. This is because the table captions will not be correctly placed in mobile portrait view, or other narrow mobile screens, when the tables wrap. This is especially noticeable if the caption is longer. In that case when one table drops below the other, then the caption will be severely wrapped above only the first column of the table.

Side by side tables and images
You can add images to the mix too. Add   to align an item to the top. See CSS vertical-align property for other options. The tables and images will wrap depending on screen width. Narrow your browser window to see. For example:



Add   to align an item to the bottom. You can choose the alignment for each item. Note the star aligned to the bottom.





You can add indentation by adding margin styling to the first div:





Float table left or right
Two table classes  and   (case sensitive) help floating the table and adjusting table margins so that they do not stick to the text. floats the table to the left and adjusts right margin. does the opposite. Example:  This paragraph is before the table. The text in column 2 spans both rows because of format specifier "rowspan=2" so there is no coding for "Col 2" in the 2nd row, just Col 1 and Col 3. Sed ut perspiciatis, unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam eaque ipsa, quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt, explicabo. Nemo enim ipsam voluptatem, quia voluptas sit, aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos, qui ratione voluptatem sequi nesciunt, neque porro quisquam est, qui dolorem ipsum, quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt, ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit, qui in ea voluptate velit esse, quam nihil molestiae consequatur, vel illum, qui dolorem eum fugiat, quo voluptas nulla pariatur?

As it appears in a browser: This paragraph is before the table. The text in column 2 spans both rows because of format specifier "rowspan=2" so there is no coding for "Col 2" in the 2nd row, just Col 1 and Col 3.

Sed ut perspiciatis, unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam eaque ipsa, quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt, explicabo. Nemo enim ipsam voluptatem, quia voluptas sit, aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos, qui ratione voluptatem sequi nesciunt, neque porro quisquam est, qui dolorem ipsum, quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt, ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit, qui in ea voluptate velit esse, quam nihil molestiae consequatur, vel illum, qui dolorem eum fugiat, quo voluptas nulla pariatur?

Note that although there are other ways to float a table, such as,  , the only parameters that allow you to position the table under a floated multimedia object are   and. For example:

Aligning the table with  produces: Sed ut perspiciatis, unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam eaque ipsa, quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt, explicabo. Nemo enim ipsam voluptatem, quia voluptas sit, aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos, qui ratione voluptatem sequi nesciunt, neque porro quisquam est, qui dolorem ipsum, quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt, ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit, qui in ea voluptate velit esse, quam nihil molestiae consequatur, vel illum, qui dolorem eum fugiat, quo voluptas nulla pariatur?

But aligning it with  produces:

Sed ut perspiciatis, unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam eaque ipsa, quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt, explicabo. Nemo enim ipsam voluptatem, quia voluptas sit, aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos, qui ratione voluptatem sequi nesciunt, neque porro quisquam est, qui dolorem ipsum, quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt, ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit, qui in ea voluptate velit esse, quam nihil molestiae consequatur, vel illum, qui dolorem eum fugiat, quo voluptas nulla pariatur?

Centering tables
is deprecated in HTML5, and does not work well in Mediawiki software. For example; it will not override the left alignment of tables via.

Centered tables can be achieved, but they don't "float"; that is to say, no text appears to either side. The trick is

Wiki markup: Text before table... ...text after table

As it appears in a browser: Text before table...

...text after table.

Nested tables
Seven 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. And  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 schematics, though as noted above, this is deprecated.

Wikitext:

Scrolling
The whole table can be placed within a scrolling div so that new table lines appear on the screen as old table lines disappear. See MOS:SCROLL, and this article discussion. A totally blind screen reader user in that discussion wrote that the scrolling tables in the related article were not a problem. There are several very advanced scrolling tables (with row and column headers that stay visible and sticky while scrolling) in COVID-19 pandemic by country and territory and in COVID-19 pandemic deaths. The scrolling and sticky headers work in cell phones too. See another scrolling table farther down:.

Color; scope of parameters
Two ways of specifying color of text and background for a single cell are as follows:

Wiki source

Rendered result

Like other parameters, colors can also be specified for a whole row or the whole table; parameters for a row override the value for the table, and those for a cell override those for a row.

  works in sortable header cells.   does not. It breaks sorting in that cell. See Help:Sorting.

There is no easy way to specify a color for a whole column: each cell in the column must be individually specified. Tools can make it easier.

Wiki markup

Rendered result

To make the table blend in with the background, use  or. (Warning:, does not work with some older browsers, including IE6, so ensure that the table will be intelligible if the coloring preference fails.)

To force a cell to match one of the default colors of the  template, use    for the darker header, and    for the lighter body. #A2A9B1 is the wikitables border color.

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

Wiki source

Rendered result

Vertical alignment in cells
By default, text is aligned to the vertical middle of the cell:

To align the text to the top of the cell, apply the  CSS to the rows (unfortunately, it seems to be necessary to apply this individually to every single row). The  attribute is obsolete and should not be used.

Wiki source

Rendered result

Horizontal alignment in cells
By default, text is aligned to the left of data cells.

By default, text is aligned to the center of header cells.

All of the above is true in both desktop and mobile view.

The alignment of header text in tables with   stays centered regardless of global right or left text alignment via   on the top line of table wikitext.

Header text alignment in tables without class=wikitable follows the global text alignment of the table.

Text alignment set in individual cells overrides everything else.

Cell content indenting and padding
The contents of a cell can be indented or padded on any side. Also, the text can be aligned. In the second row the text is aligned to the right. See the following examples.

Wiki source

Rendered result

The arguments to  can be seen as being ordered by a 12-hour clock, starting at noon and going clockwise, in the following sense: "top" is associated with noon (i.e. 12 o'clock, the top of a clock), "right" is 3 o'clock, "bottom" is 6 o'clock, and "left" is 9 o'clock. The arguments are ordered clockwise starting at noon: top &rarr; right &rarr; bottom &rarr; left (see this footnote for an example with an explanation).
 * Pattern for arguments:

This same order is also used elsewhere, such as when specifying a cell's borders with.

Individual cell borders
The same CSS used for tables can be used in a cell's format specifier (enclosed in ... ) to put a border around each cell:

Wiki source

Rendered result

Note that only the image cells have individual borders, not the text. The lower hex-colors (such as: ) are closer to black. Typically, all borders in a table would be one specific color.


 * Top, right, bottom, and left borders of a cell

To set the left, right, bottom, or top border of a single cell, one may use  which takes 4 arguments, each of which is either   or. These arguments are ordered according to the pattern described here. For instance,  where the four parameters correspond respectively to the

borders of the cell. For reasons described after this example, there are many ways to change the following that would  result in any changes to the table that is actually.

Wiki source

Rendered result

Note, however, that in the following table, none of the central cell's (i.e. 's) borders are removed despite the code  :

Wiki source

Rendered result

This happens because the code  places a border (top, right, bottom, and left) around  cell in the table so that, for instance, there are actually  borders between the cells "Middle_Center" and "Middle_Right". So to remove the border between cells "Middle_Center" and "Middle_Right", it is necessary to remove both the right border of "Middle_Center" the left border of "Middle_Right":

Wiki source

Rendered result

Note that replacing  with

has the effect of removing all cell borders that would otherwise appear by default around every cell in the table. With this change, you must a  cell border between two adjacent cells rather than remove  cell borders.

Row numbers
See Help:Sorting sections on row numbers. And:
 * Template:Static row numbers
 * Template:Row numbers

Setting column widths
To force column widths to specific requirements, rather than accepting the width of the widest text element in a column's cells, follow this example. Note that wrap-around of text is forced.

Wiki source

Rendered result

To set column widths in a table without headers, specify the width in the first cell for each column.

Wiki source

Rendered result

You can also use percentages, such as to equalize the widths of a two-column table by setting one of them to.

One application of setting the widths is aligning columns of consecutive tables. The following are separate tables, with columns set to 350px and 225px.

Wiki source

Rendered result

Nowrap
In a table that spans the entire width of a page, cells narrower than the widest cell tend to wrap. To keep an entire column from wrapping, use  in a non-header cell on the longest/widest cell to affect the entire column.

Without, as it appears in a browser:

Wiki source

Rendered result

With, on both the Episode and Date columns, as it appears in a browser:

Wiki source

Rendered result

Tooltips
You can add tooltips to columns by using the H:title template. Simply replace the column-title with, which makes it appear like so: Column title.

Mélange
''Note: This example is not accessible, and should be avoided as much as possible. For example, nested tables (tables inside tables) should be separated into distinct tables when possible.''

Here is a more advanced example, showing some more options available for making up tables.

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

Wiki markup:

As it appears in a browser: Text before centered table... ...text after centered table

Floating images in the center
A table can be used to wrap an image, so that the table can float towards the center of the page (such as using: ). However, the table margins, border and font-size must be precisely set to match a typical image display. The File-spec parameter  (although auto-thumbnailing to user-preference width) forces a wide left-margin that squeezes the nearby text, so the parameter   can be added to suppress the left-margin padding. However,  sometimes shoves the caption to a 2nd line (under a centered box "[]"), so   could be omitted and just hard-code the image size, adding a gray (#BBB) border. Using precise parameters to match other images, a floating-image table can be coded as follows:

The text inside the floating table is sized by. That floating-image table floats a typical image box, but allows adjusting the left-hand margin of the image (see temple-example floating below). The caption text can be omitted, or remove the parameter "thumb|" so the caption is hidden until "mouse-over display". Unfortunately the parameter  (used for displaying the caption) also controls the auto-thumbnailing to re-size images by user-preferences size. To have auto-thumbnail sizing while also concealing the caption, use  instead of.

An image set with parameter  has a wide right-side margin (opposite margin of parameter  ), so floating toward the left can be achieved with an image set as   inside a table with style="float:left; margin:0.46em 0.2em;".

Recall that, outside an image-table, the parameter  causes an image to align (either) above or below an infobox, but would not float alongside the infobox.

Note the : first come infoboxes or images using, then come the floating tables, and lastly, any text wraps that can still fit. If the first word of the text is too long, no text will fit to complete the left-hand side, so beware creating a "ragged left margin" when not enough space remains for text to fit alongside floating tables.

If multiple single-image tables are stacked, they float to align across the page, depending on page width. The text squeezes to allow as many floating tables as can fit, as auto-aligned, then wrap whatever text can still fit at the left-hand side.

That auto-aligning feature can be used to create a "floating gallery" of images: a set of 20 floating tables wrap (backward, right-to-left), as if each table were a word of text to wrap across and down the page. To wrap in the typical direction (wrapping left-to-right) define all those floating tables, instead, as left-side tables using the top parameter. Multiple floating images empower more flexible typesetting of images around the text.

Combined use of COLSPAN and ROWSPAN
Wiki source

Rendered result

Note that using  for cell G combined with   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  to fill an empty cell with dummy content.

Below is the same table with the order of the declared rows and cells shown in parentheses. The uses of  and   are also shown.

Note that although cell C is in column 2, C is the 1st cell declared in row 3, because column 1 is occupied by cell A, which was declared in row 2. Cell G is the only cell declared in row 5, because cell F occupies the other columns but was declared in row 4.

Decimal point alignment
Unfortunately, the only way to align columns of numbers at the decimal point is to use two columns, with the first right-justified and the second left-justified.

Wiki source Rendered result

If the column of numbers appears in a table with cell padding or cell borders, you can still align the decimal points without an unsightly gap in the middle, by forcing the border and padding between those two columns off.

Wiki source Rendered result

Or alternatively the decimal cell template can be used:

Wiki source Rendered result

Using two columns like this does have the disadvantage that searching the web page (either with a browser or a search engine) will usually not be able to find text that straddles the column boundary.

Also, if the table has cell spacing (and thus ), meaning that cells have separate borders with a gap in between, that gap will still be visible.

A cruder way to align columns of numbers is to use a figure space, which is intended to be the width of a numeral, though is font-dependent in practice:

Wiki source Rendered result

More companions in this line are: punctuation space (&#x2008;) to substitute a period or a comma, &minus; instead of the easily available on the typewriter&#x27;s keyboard hyphen-dash – this is the same width as the plus sign, also figure dash possibly the most useful for telephone numbers which you obviously will not find on Wikipedia.

When using OpenType fonts one may also alternate between font-variant-numeric:tabular-nums and font-variant-numeric:proportional-nums – this is especially visible in the kerning of Arabic digit &lang;1&rang;. In the standard browser sans-serif fonts &lang;1&rang; occupies the same width as other digits, ie. works as if font-variant-numerals:tabular-nums was turned on.

Some may find 0 useful for the alignment.

As a last resort, when using pre-formatted text, you can dispense with the table feature entirely and simply start the lines with a space, and put spaces to position the numbers—however, there should be a good reason to use pre-formatted text in an article:

Wiki source (just spaces!): Rendered result 432.1 43.21   4.321

Non-rectangular tables
can be used to diagonally split a header cell, as in the top-left cell in the rendered result below:

Wiki source Rendered result

Cell borders can be hidden by adding to style attributes of either table or cell (may not work in older browsers). Another use is to implement multi-column aligned tables.

Wiki source Rendered result

Wiki source Rendered result

Classes
There are several other CSS classes, besides the basic, documented above.

In the first line of table code, after the, instead of specifying a style directly, you can also specify a CSS class, which may be used to apply styles. The style for this class can be specified in various ways:
 * in the software itself, per skin (for example the class sortable)
 * collectively for all users of one wiki in MediaWiki:Common.css (for example, on this and some other projects there is or was the class wikitable, later moved to shared.css)
 * separately per skin in MediaWiki:Monobook.css etc.
 * individually on one wiki in a user subpage
 * 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 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:

Wiki source Rendered result

becomes this:

Wiki source Rendered result

simply by replacing inline CSS for the table by. This is because the  class in MediaWiki:Common.css contains a number of   CSS 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:

Wiki source Rendered result

Notice that the table retains the gray background of the  class, and the headers are still bold and centered. But now the text formatting has been overridden by the local  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.

Collapsible tables
Classes can also be used to collapse tables, so they are hidden by default. Use the class to enable collapsing behaviour. Collapsible tables can be sortable, too, by also including the  class. By default, a collapsible table begins expanded. To change this, add the additional class. Alternatively, you can add, instead of , which will automatically collapse the table if two or more collapsible elements are present on the page.

Note: Previous versions of this article recommended the  class, but  is now preferred. It is a feature of the MediaWiki software, not a local customization, and can be used to make any element collapsible, not just tables. also does not require a header row in the table, as  did. Tables will show the "[hide]" / "[show]" controls in the first row of the table (whether or not it is a header row), unless a table caption is present.

Example with a header row
Wiki source Rendered result

Examples without a header row
Wiki source Rendered result

Wiki source Rendered result

Tables with captions
Tables with captions will collapse to the table caption. The header will not be visible when collapsed. Use nowrap to keep the caption from being fit into a tiny vertical column when the table is collapsed.

Wiki source '''Rendered result. Click "hide" to see'''

Rendered result (without . Click "hide" to see

Starting off collapsed: Wiki source '''Rendered result. Click "hide" to see'''

Rendered result (without . Click "hide" to see

Sortable tables
Tables can be made sortable by adding  to the top line of the table wikitext. For details see Help:Sorting.

Sorting and collapsing
It is possible to collapse a sortable table. To do so, you need to use this code:

For example:

Wiki source

Rendered result

If you want the table to default to collapsed state, use the code

in place of

mw-datatable – row highlighting via cursor hover. White background

 * Note:  is not working in some skins. See  and this discussion.
 * Note:  overrides background color for a row, but not the background color for individual cells.

allows for row highlighting. This makes it easier to follow the data and info across a row, especially in wider tables.

mw-datatable use is found with this global search within wikitext across all Wikimedia Foundation wikis. See bottom of search results for English language wiki use. See next section for one possible replacement.

tpl-blanktable – row highlighting via cursor hover. White background
This replaces  (see previous section) for now. It does not override existing background colors set for cells or rows.

See Template:Import-blanktable. Add  in the wikitext anywhere before the table wikitext.

Add  to the top of the table wikitext.

To see where and how it is used:
 * Special:WhatLinksHere/Template:Import-blanktable

Scroll your cursor over the tpl-blanktable tables below to see the light blue hover banding.

  produces a white background for data cells; while   produces a gray background for data cells:

Wiki source

Rendered result

Wiki source

Rendered result

  can be used in combination with class  

Wiki source

Rendered result

Cells spanning multiple rows or columns
It is possible to create cells that stretch over two or more columns. For this, one uses. Similarly, one can create cells that stretch over two or more rows. This requires. In the table code, one must. The resulting column- and row-counting must fit.

Wiki source

Rendered result

In the code, the cell  spans two columns. Note that, in the next column,.

Similar: in the code, cell  spans two rows. .

Section link or map link to a row anchor
To enable a section link 's anchor (or a map link's anchor), referencing a specific row within a table, an  parameter needs to be added to the row start   or  :

Note that each section link anchor name must be different from every other in the page (this includes heading names), to create valid XHTML and allow proper linking.

When a country label, containing a link, is clicked on the map, the link coded, for example, as  that references the anchor (within the table), coded as , makes the page scroll so selected row of the table is at the top of the browser view. Here, we use the template family, , and to lay out such a table for us:
 * Example of a map link to a row

Click on a country name on the map to go to that name in the table

Row template
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, may have much in common, e.g.: In such a 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:
 * the basic code for a table row
 * code for color, alignment, and sorting mode
 * fixed texts such as units
 * special formats for sorting
 * 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  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

Example:

Using

Wiki source

Rendered result

Conditional table row
For a conditional row in a table, we can have:

Wiki source

Rendered result

With comments to explain how it works, where note how the second row is missing:

Wiki source

Rendered result

Other table syntax
The types of table syntax that MediaWiki supports are:
 * 1) Wikicode   syntax
 * 2) HTML (and XHTML)
 * 3) Mixed XHTML and wikicode (Do not use)

All three are supported by MediaWiki and create (currently) valid HTML output, but the pipe syntax is the simplest. Mixed HTML and wikicode  syntax (i.e., unclosed   and   tags) don't necessarily remain browser-supported in the future, especially on mobile devices.

See also HTML element. Note, however, that the,  ,  ,  , and   elements are currently not supported in MediaWiki,.

Comparison of table syntax
! scope="row" | Pros ! scope="row" | Cons
 * - style="vertical-align: top;"
 * Can preview or debug with any XHTML editor
 * Can be indented for easier reading
 * Well-known
 * Insensitive to newlines
 * No characters like "|", which can collide with template and parser function syntax
 * Easy to write
 * Easy to read
 * Takes little space
 * Can be learned quickly
 * - style="vertical-align: top;"
 * Can be learned quickly
 * - style="vertical-align: top;"
 * Tedious
 * Takes a lot of space
 * Difficult to read quickly
 * Debugging more difficult because of tag pairing requirements
 * Indented code might not match nesting.
 * Confusing newline behaviour as they only occasionally break cells.
 * Unfamiliar syntax for experienced HTML editors
 * Rigid structure
 * Cannot be indented for clarity
 * HTML tag text may be easier to read than pipes, plus signs, dashes, etc.
 * Requires using to pass a   character in a parameter.
 * Sensitive to newlines; see Help:Newlines and spaces.
 * }
 * Sensitive to newlines; see Help:Newlines and spaces.
 * }

Pipe syntax in terms of the HTML produced
The pipe syntax, developed by Magnus Manske, substitutes pipes and other symbols for HTML. There is an online 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.

Tables
A table is defined by, which generates .

Rows
For each table, an HTML tag is generated for the first row. To start a new row, use: |- which generates another.

Parameters can be added like this: |- params which generates.

Note:
 * tags are automatically opened before the first equivalent
 * tags are automatically closed at another equivalent and at the  equivalent

Cells
Cells are generated either like this: |cell1 |cell2 |cell3 or like this: |cell1||cell2||cell3 which both generate: cell1cell2cell3. The  equals a newline +.

Parameters in cells can be used like this: |params|cell1||params|cell2||params|cell3 which results in: cell1 cell2</td> cell3</td>

Headers
The code used produces a <th ></th>, functioning the same way as </td>, but with different style and semantic meaning. A  character is used instead of the opening , and   can be used like  , to enter multiple headers on the same line. Parameters still use "|", though. Example: ! params|cell1

Captions
A tag is created by which generates the HTML <caption >caption</caption>.

You can also use parameters: |+ params|caption which generates <caption >caption</caption>.

Table cell templates
Table cell templates provide a set of templates to configure text and color in cells in a standard way, producing stock output such as "Yes", "No", and "n/a", on coloured backgrounds.

Vertically oriented column headers
Sometimes it is desirable (such as in a table predominantly made of numbers) to rotate text such that it proceeds from top to bottom or bottom to top instead of from left to right or right to left. Formerly, browser support for this type of styling as a component of HTML or CSS was sporadic (Internet Explorer was one of the few browsers that supports this in cascading stylesheets, albeit in a non-standard way).

Enclose the text of each heading in a vertical header template. For example: If the text includes an equals sign then replace it with.

An alternative solution that works in most if not all browsers is to use images in place of the text. For instance, the following table uses SVG images instead of text to produce the rotated column headers:

Normally, one problem with this approach is that readers are directed to different pages when they click on the images. To eliminate this problem—or to direct readers to a page—you can use the   parameter of the   specification. A column header can be coded as follows:

The image wikilinks to the page Wikipedia:WikiProject Video games.

By setting the link to an empty string (e.g. ), no navigation occurs when visitors click on an image. Note that it might also be a good idea to color the image text blue if you are using the images as links. Also, SVG is the preferred image format in this case because it can be re-scaled to any size while producing fewer artifacts.

A more serious potential problem is that the "rotated text" is not text that can be used by screen readers and other technologies for visually disabled users. So those users wouldn't be able to "read" the column headers. Also, automated search engine Web crawlers would not be able to read it either. This is solved by always using the  parameter in the   specification of each image to provide the same text as in the rotated image; see   in the example above.

Wikitable as image gallery
A wikitable can be used to display side-by-side images, in the manner similar to that of an image gallery (formatted by <gallery ></gallery>), but with larger images and less vacant area around photos.

A simple, framed gallery can be formatted using  to generate the minimal thin lines around images within the table:

An advantage of wikitable image galleries, compared to formatting, is the ability to "square" each image when similar heights are needed, so consider putting two-number image sizes (such as  ), where the second number limits height:

Note the three images sized  appear identical height, of   (the fourth image purposely smaller). The "95px" forces height, while  fits the various widths (it could even be  ): Therefore, the use of size  (or , or whatever) produces the auto-height-sizing beyond the  tag, and with the option to set taller thumbnails , or even to have some images purposely smaller than other images of   height. A very short height (e.g. ) allows many more images across the table:

The above wikitable-coding produces the result below, of 7 columns:

Once images have been placed in a wikitable, control of formatting can be adjusted when more images are added.

Shifting/centering
Images within a wikitable can be shifted by inserting non-breaking spaces before or after the image code (e.g., ). However, auto-centering simply requires use of the center parameter (see WP:Extended image syntax).

In the example below, note how Col2 uses center, but Col3 uses : The above coding generates the table below: note the middle garden image is centered (but not the left image), and the right image has 2 spaces before "View...", to give an approximation of centering: Also note that the tag <small ></small> made a smaller-text-size caption. Fonts also can be sized by percent, where the exact percent-size as displayed depends on the various sizes allowed for a particular font; the browser will approximate to the nearest possible size. | style="font-size: 87%;" | View from bell tower The column attribute, above, uses  to set the font size for the caption, following the second pipe symbol.

A  is excessively small, while   is a mid-size font, slightly larger than that produced by the tag.

Indenting tables
While tables should not normally be indented, when their surrounding paragraphs are also indented, you can indent tables using one or more colons (":", the normal indent code) at the beginning of a line, the same way you'd indent any other wiki content.

Note that indentation applied to only the first line of the table definition (the line that begins with " ") is sufficient to indent the entire table. Do not attempt to use colons for indentation anywhere within the rest of the table code (not even at the beginning of a line), as that will prevent the MediaWiki software from correctly reading the code for the table.

Wiki source

Rendered result
 * {| class=wikitable

! Header 1 ! Header 2
 * row 1, cell 1
 * row 1, cell 2
 * row 2, cell 1
 * row 2, cell 2
 * }
 * row 2, cell 2
 * }

The same table without indentation would be like this:

Wiki source

Rendered result

Adding flags and linking country names in country lists

 * This is fast. It works with compact or long table wikitext. Single or double bars between cells.
 * Note: User:PrimeHunter (Talk) provided the code. Ask him for help.
 * Note: In editing preferences check the box: "enable the editing toolbar. This is sometimes called the '2010 wikitext editor'."

Make sure the countries, states, provinces, or cities, etc. are in the first column. The regular expression wraps all the text in the first cell of each row with the template. So do this before adding any styling to the first column.

Click on the wikitext source editing link. Click on "Advanced" in the editing toolbar. Then click on the search and replace icon on the right. Put a check in the box called "Treat search string as a regular expression." Fill in the "Search for" box with:

Fill in the "replace with" box with:

Then click "Replace all". Nearly all countries will be linked and will have flags.

For the red links create redirects as necessary to the correct country data templates. Save this initial table permanently in a user sandbox without overwriting it. This is so that the redirects are kept due to being in use on that sandbox page. Otherwise, admins will delete unused redirects, and you will have to do this tedious, time-consuming redirect task every time you fully update the table. In the edit summary of such redirects, add something like this: "Please do not delete this redirect. It is sometimes used in updates of NAME OF ARTICLE WITH TABLE."

Adding links to specialized country, state, or territory articles
For example:
 * List of U.S. states and territories by incarceration and correctional supervision rate
 * List of countries by incarceration rate

Once you have a table with flaglist or other flag template it is easy to convert the links to specialized links. So instead of Oklahoma you would have Incarceration in Oklahoma, or if that article does not exist, then Crime in Oklahoma.

Use a global find-and-replace as previously described, but without regular expressions. Replace:

with

The flagg template looks for the articles. If it finds one of the two choices it adds the link and an asterisk after the state, country, territory, or other subnational area name. If it does not find either article, it just adds the standard link.

Substitute your preferred topics in the pref= and pref2= spots.

This particular use of flagg parameters is expensive and can only be used on a few hundred links per article. Every time the article is saved it occurs, even for null edits. So only one big country table per article. Other country tables in the same article should use standard links.

In List of countries by incarceration rate the flagg template creates a link to Incarceration in United States. That link is a redirect to Incarceration in the United States. Add "the" as necessary to create redirect pages. Admins will delete redirects that are not linked from within Wikipedia. So if you need to create redirects be sure to use them right away in an article table. Or keep them in a sandbox that the admins can see until you use them in an article table. See examples. See list.

The use of  is found with this global search within wikitext.

Add link brackets to text in each cell in a column

 * Note: User:PrimeHunter (Talk) provided the code. Ask him for help.
 * Note: In editing preferences check the box: "enable the editing toolbar. This is sometimes called the '2010 wikitext editor'."

List of countries by intentional homicide rate has a main table with a region column and a subregion column. Here below is a fast way to link the regions and subregions in those columns. For example, after updating the whole table from the source. See example in this sandbox.

The following assumes the syntax is a whole table row in one source line starting with a pipe and with double pipe between cells.

Click on the wikitext source editing link. Click on "Advanced" in the editing toolbar. Then click on the search and replace icon on the right. Put a check in the box called "Treat search string as a regular expression." Fill in the "Search for" box with:

Change "m" to the number of the column minus 1. 2nd column from the left would be "1". 3rd column from the left would be "2". The row number column created by Template:Static row numbers is not counted in these calculations. Fill in the "replace with" box with:

Then click "Replace all". The "m" number may be different if a table uses rowspan or colspan.

If you then want to left align the region and subregion links do a simple find and replace. Replace the left brackets:

with:

Aligning text in header cells versus other cells
If there is no global text alignment set in the top line of the table wikitext, then all text is left aligned, except for header cells which are default center aligned.

Only in tables with   does the header cell text not follow the global text alignment set in the top line of the table wikitext.

When using   header text now stays centered in both desktop and mobile view unless specifically changed per header cell. This is true wherever the header row is located (top, bottom, middle). Global text alignment for non-header cells is done by putting   in the top line of the table wikitext. See example in the next section.

Aligning the data in data columns to the right
Both tables below use   The table to the right also aligns the text and data in all cells (except header cells) to the right.

If most columns consist of data cells, then you might choose to align the data to the right. It is easy. Just add  to the top line of the wikitext for the table:

or

and so on.

Aligning the text in the first column to the left
This can be done in the wikitext source editor. In editing preferences check the box labeled: "enable the editing toolbar. This is sometimes called the '2010 wikitext editor'."

In the table section click "edit source" (wikitext editing). Click on "Advanced" in the editing toolbar. Then click on the "search and replace" icon on the right. In the popup form check the box for "Treat search string as a regular expression".

Fill in the "Search for" box with Fill in the "replace with" box with

Then click "Replace all". All the text in the first column will be aligned to the left of their cells.

If for some reason those cells are header cells, then fill in the "Search for" box with

Note the exclamation point for a header cell. Fill in the "replace with" box with

Then click "Replace all".

Converting spreadsheets and database tables to wikitable format
To convert from spreadsheets (such as those produced by Gnumeric, Microsoft Excel, or LibreOffice/OpenOffice.org/StarOffice Calc), you can use the Copy & Paste Excel-to-Wiki converter, tab2wiki, or the MediaWiki Tables Generator.

You can save spreadsheets as .csv and use the CSV to Wikitable converter. Another version is here.

The CSV Converter converts comma-separated values (CSV) format to table wikitext or to HTML. See (documentation). You may use this to import tables from both spreadsheets and databases (such as MySQL, PostgreSQL, SQLite, FileMaker, Microsoft SQL Server & Access, Oracle, DB2, etc.).

Converting rows to columns and columns to rows
Sometimes there is a need to transpose columns and rows (move rows to columns, and columns to rows). For simple tables, this can be done via the "transpose rows and columns" function of Copy & Paste Excel-to-Wiki, or via the "transpose" feature of a third-party spreadsheet program such as Microsoft Excel, the free web-based Google Sheets, or the free downloadable software LibreOffice Calc.

To transpose the table with a third-party spreadsheet program, copy the published table on the Wikipedia page and paste it into a new blank document in your spreadsheet program. While the pasted cells are still selected in the spreadsheet, copy them again by right-clicking and choosing "Copy" from the context menu. Open a new blank spreadsheet spreadsheet, click in the upper-left cell, right click on it, and choose "Paste Special". In Microsoft Excel, check the "Transpose" box at the bottom of the dialogue and hit Okay. In Google Sheets, choose "Transposed" from the sub-menu. in LibreOffice Calc, choose "Transpose" from the sub-menu. Perform any required editing of the transposed table, and copy the new table directly from the spreadsheet program into visual editor, or into one of the wikitable converters previously mentioned, such as toolforge:excel2wiki or tab2wiki.

For more complicated operations, such as consolidating multiple rows with the same header into a single column, you can use the "pivot table" feature of an external spreadsheet program. For example; the data for the overdose rates table by state for United States drug overdose death rates and totals over time comes from a csv file and is converted to wikitable format via one of the previously mentioned csv converters, but the year headers in the left table below need to become the column headers in the right table (truncated).

To re-arrange the table using pivot tables, copy and paste the published Wikitable into a spreadsheet program such as freeware LibreOffice Calc.

In LibreOffice Calc, select a data cell. Then click on the "Pivot Table" command from the Insert menu. Click OK in the popup box. In the next dialog box drag "Year" to the "Column Fields" box, and drag "State" to the "Row Fields" box. Drag "Rate" to the "Data Fields" box. Click OK. The table will convert to the new format with the years as column headers. It is easier to do than to describe. For help see: LibreOffice: Pivot Tables and LibreOffice Help: Pivot Table.

If further editing is required, first copy and paste that table to a new Calc spreadsheet, to prevent complications with the existing interactive pivot table. When done editing, copy the new table (if small) directly from the Calc page into visual editor, or into one of the wikitable converters previously mentioned, such as Copy & Paste Excel-to-Wiki or tab2wiki. Then use VE to delete the summation column and row.

List of countries by intentional homicide rate has a country table that uses a source with multiple years. But the table only shows data for the latest available year for each country. Some more complex transposing needs to be done with the source spreadsheet. To do it quickly see these threads:
 * How can I see only the latest year for each country in a spreadsheet? - for Calc.
 * Reference desk/Archives/Computing/2021 October 28 - for Excel.

Picking selected dates from massive .csv files
COVID-19 pandemic deaths has a few tables by year of cumulative deaths by country on the first of each month. The source is a massive WHO (World Health Organization) csv file. Download here. You could convert it to a massive wikitable as described elsewhere, and delete the hundreds of unwanted date columns over several hours.

Or you could open the csv file in a spreadsheet such as freeware LibreOffice Calc. Then delete all columns except for "Country", "Date reported", and "Cumulative deaths" columns (select, right-click column head, delete). Save as .ods file. Then use the autofilter function to select just the dates of interest from a checklist. Click anywhere in the table. Then: Data menu > AutoFilter. Dropdown menus will show up on all column heads. In the "Date reported" dropdown menu clear the "All" box by clicking it. This unchecks all the dates. Then check the dates you want. In this case all the first of the month dates for the desired year. Click OK. Save the file. See video. See: "Applying AutoFilter" in Calc help.

In order to completely remove all the unwanted data you must copy and paste that table to a new Calc ods file. A simple paste works (edit menu > paste). This greatly reduces the file size. See: "Only Copy Visible Cells" in Calc help.

On this smaller file use the "Pivot Table" method described in the previous section to put the dates as column heads. Select a data cell. Then click on the "Pivot Table" command from the Insert menu. Click OK in the popup box. In the next dialog box drag "Date reported" to the "Column Fields" box, and drag "Country" to the "Row Fields" box. Drag "Cumulative deaths" to the "Data Fields" box. Click OK. Copy and paste that table to a new Calc ods file to prevent Pivot complications, and to do further editing.

Add thousands separator as needed as described in another section. Sort latest month. Save it. Then copy that Calc table to tab2wiki, or to the VisualEditor (if small). For more info go here.

This method can be used for creating or updating many Wikipedia country tables that need only the latest data, or selected dates, from large multi-year data file sources. Just scrolling back and forth through one huge data file could take hours otherwise.

Automated tables updated daily by bots
Some automated tables: The next 2 templates are the same, except one is scrolling and one is not.
 * Template:COVID-19 pandemic data. Scrolling. Used here: Portal:COVID-19.
 * Template:COVID-19 vaccination data. Scrolling. Used here:
 * Deployment of COVID-19 vaccines
 * Template:COVID-19 pandemic death rates. Scrolling. Used here:
 * COVID-19 pandemic by country and territory
 * Template:COVID-19 pandemic death rates by country. Not scrolling. Used here:
 * COVID-19 pandemic death rates by country.

Tables and the Visual Editor (VE)
See T108245: "Fully support basic table editing in the visual editor". See the list of tasks. Finished tasks are struck. It can be difficult to figure out from the technical language there what exactly has been improved, or what features have been added. Please add explanatory info below.

Sandboxes help a lot. For example; your user page: Special:MyPage. Create and bookmark some personal sandboxes too. Visual Editor will load very fast in empty sandboxes: Special:MyPage/Sandbox, Special:MyPage/Sandbox2, Special:MyPage/Sandbox3. As many as you want. Share the link when asking for help. To find all your sandboxes: Special:PrefixIndex/User: – click link, add user name to the spot labeled "Display pages with prefix:".

Insert blank row or column
Click on a column or row header. Then click on the arrow. From the popup menu click on "Insert".

Move or delete columns and rows
In VE click on a column or row header. Then click on the arrow. From the popup menu click on "Move" or "Delete". In freeware LibreOffice Calc select the column or row. Then click and hold the Alt key. Then drag the column or row where you want it. You can drag from anywhere in the row or column except for the row number or column letter.

Copy column from one table to another
This is useful for many things. For example; for quickly updating country lists, or adding/updating a rank column. See Help:Sorting about rank columns and row numbers. See also: Commons:Convert tables and charts to wiki code or image files. See the section on updating List of countries by incarceration rate.

Launch the Visual Editor. In the column you are copying click the header cell or whatever top cell you want. Then shift-click a cell farther down or at the end of the column. This will select the column down to that cell. Then click "copy" from the edit menu of your browser. In some browsers you can do this from the popup context menu. Then click any blank spot on the page to deselect the column.

Go to the column you want to replace or fill in (in this table or another one). Be sure visual editor has been launched. If you are copying the whole column including the header cell select just the header cell for that column by clicking on it. Then click "paste" from the edit menu of your browser. You can paste into a blank column the same way. Just select the header cell. Then from your browser: edit menu > paste.

Or you can select part of a column and paste into it. For example; if you don't want to replace the header cell.

All of the above will sometimes work when copying to or from a column in a spreadsheet (such as freeware LibreOffice Calc). If there is a problem, then paste that spreadsheet column into tab2wiki first, and copy the wikitext.

After combining the columns into one table, you may notice that VE created a mishmash of compressed and uncompressed wikitext. If this is a problem, it can be fixed by pasting the table into tab2wiki.

Note: The Visual Editor will copy templates (as in a column of country/state/province names with flag templates), but it will not copy inline styling such as styling used to left align those names. That can be added back all at once in any text editor. For example; if the flag template is the only template in the table, then replace  with

Copy or delete multiple rows
Click on the top corner cell of the area you want to select. Then shift-click on the opposite top corner cell in the same row. Then go straight down and shift-click on the bottom corner cell on the same side of the area you want to select. You will now have a rectangle or square selected of the table.

Click on "copy" or "cut" as needed from the edit menu of your browser. "Delete" will not work for multiple rows and columns.

Click on the top left corner cell of the area you want to paste into in a table. Then click "paste" from the edit menu of your browser. It can take from a few seconds to up to a minute for very large areas. You might want to do this work in a sandbox first. Then save and edit further before putting anything in an article.

"Cut" will empty the selected cells. It does not delete them. Once empty though it is very easy to delete all the empty cells, rows, and columns in the source editor. Switch over to it by clicking the arrow at the top right of the editing window.

It may be even faster to use the Visual Editor to copy the parts you want from the table into a new blank table.

Copy table from web page to Visual Editor
It is now possible to copy and paste some tables from a web page directly into the Visual Editor (VE). Not all tables work. Use an empty sandbox to do this most quickly. Save it, and edit further before pasting it into an article.

Select the table on the web page. Then click "copy" from the edit menu of your browser. In some browsers you can do this from the popup context menu. Launch visual editor on any page. Then paste the table into the page.

If that does not work, click on the insert menu, and then "table". It usually has the first header in the table selected. Then click on "paste" from the edit menu of your browser. It may take awhile for the table to show up. It can take 3 seconds, or up to a minute for very large tables.

Copy table from web to Excel2Wiki to wikitext editor to VE
For copying web page tables that can't be copied directly into the Visual Editor (as described in the previous section): Try copying the table into Excel2Wiki, or tab2wiki. Click "convert". Copy and paste the table wikitext into the wikitext editor. Save. Do further editing in VE.

Copy list (not in table) to Excel2Wiki to wikitext editor to VE
Paste any list (text and/or numbers) into Excel2Wiki. Click "convert". Copy and paste the table wikitext into the wikitext editor. Save. Do further editing in VE. For example; add more columns, or copy the column and paste it into other tables. Before pasting a list into Excel2Wiki you may want to remove a block of text. Some text editors can do this when text is set to a fixed-width font such as Courier New. For example; freeware NoteTab Light: Modify menu > Block > Cut. Fill in popup form with starting column, block width, block rows. Click OK and that rectangle of text is removed. This saves a lot of time.

Sort alphabetically or numerically with free spreadsheet and VE

 * Note: For more info see Help:Sorting. See the section on putting a table in initial alphabetical order.

Many things can be done in spreadsheet programs that can not be done in the visual editor. Select and copy a table right off of a page (do not go into the wikitext or the HTML). Paste the table into a spreadsheet program such as freeware LibreOffice Calc (see free guide), or another spreadsheet program. See List of spreadsheet software.

In Calc click on any cell in the column you want sorted, and then click on one of the sort options in the data menu at the top of the Calc window. Click on "ascending" or "descending" to sort alphabetically or numerically depending on the column contents. Click on "sort" for more options.

To move the header row(s) back up to the top: Select the entire row(s). To select the entire row(s) click on the Calc numbered columns located on the far left of any sheet. Press and hold ALT key. Left click and hold any cell within that section (row numbers won't work). Using the mouse drag and drop the source row(s) to its destination. Release the mouse button.

To avoid this problem when doing an alphabetical sort, select all of the table except the header rows. To do so with multiple columns click the top left non-column-header cell, and then shift-click the bottom right cell. When you click on "ascending" or "descending" in the data menu the table will be sorted alphabetically. That is the default.

Paste that sorted table (or just the selected columns of interest) into a new table in Visual Editor. Copy directly from the spreadsheet, and then paste directly into a new Visual Editor table where the first header cell has been selected. It may take up to a minute. If there is a problem, then paste into tab2wiki first, and copy the wikitext.

Copy table from PDF to Visual Editor
Upload PDF to free online PDF-to-Excel site. For example; here. Download the Excel file. Open it in freeware LibreOffice Calc or another spreadsheet program. If you just want one table from a long Excel page, you can select that table from the Calc page. Then copy the table to a new page in Calc.

Edit and move columns and rows in Calc. To drag a column first select it by clicking its header number. Then press and hold the ALT key. Then click a data cell, and drag the column to a new location. Or right click and delete the selected column (no need for ALT key). Rows are similarly moved (with the ALT key pressed), or deleted. Sort as described in the previous section.

Copy the table to a wiki sandbox. In Calc select the table. Copy directly from it, and then paste into a new Visual Editor table where the first header cell has been selected. It may take up to a minute. If there is a problem, then paste into tab2wiki first, and copy the wikitext.

Add commas or periods to separate every third digit in numbers
Countries use commas, periods, and spaces to separate every third digit in numbers. See: Thousands separator.

To replace spaces with commas or periods, paste the list, row, or column into a text editor (Notepad for example). Use replace (from edit menu in Notepad). See previous sections to learn how to copy that corrected list into a table.

If you are already in a spreadsheet use find-and-replace after selecting the column or row in question.

If there is no separator between every third digit, then paste the list, row, or column into a spreadsheet (LibreOffice Calc for example). To do that click the first column head in the blank spreadsheet. This will select that column. Then click paste from the edit menu of Calc. From the popup box click "fixed width". Uncheck everything else. Click OK. This will paste it into the first column. In Calc save it in the default .ods format. This will allow the next step.

If there are multiple columns select the top left data cell (not the header cell or this will not work). Then Shift-click on the bottom right data cell. This will select all the data cells. Don't select any text or date cells. Or deselect just the text or date cells by ctrl-click.

Click "number format" from the format menu. Then click "thousands separator" from the submenu. This will add commas or periods depending on the default language you have selected in Calc for the locale setting. (tools menu > options > language settings > languages > formats > locale settings). For example; with English you might select USA, UK, South Africa, or one of the many other English speaking countries that are listed for English. Copy that column to a Wikipedia table via VE.

Consider also a parser function and template Formatnum (see ), and familiarizing yourself with Manual of Style/Dates and numbers.

Round off numbers (usually to zero decimal places)
Most of the time, especially with dollars and cents, the data is more useful to readers when rounded off to no decimal places.

It is easy to do in a spreadsheet. For example; in LibreOffice Calc select the column by clicking the very top of its column. Then go to the Format menu > Cells. A popup will show up. Click the "Number" category. Choose the number of decimal places (zero if you don't want any decimal points). You can also choose from the example list.

That popup page is also where you choose a thousands separator or not. Choosing from the example list will also check or uncheck that box. When done copy that table or column to a Wikipedia table via VE. If there is a problem, then paste into tab2wiki first, and copy the wikitext.

Summing or averaging a list of numbers
Launch VE. In a table select a column, or part of a column of numbers. To do so click the top cell you want. Then shift-click a cell farther down or at the end of the column. This will select the column down to that cell. If this is not possible, you may need to first comment out, or temporarily delete some table templates such as those for Static row numbers. Use a sandbox.

Upon selection in VE you will immediately see a popup box with a sum total of the selected cells, and an average.

Templates

 * Category:Table templates: all the templates that use tables.
 * Category:Multi-column templates: templates for using columns without tables.
 * Category:Chart, diagram and graph templates
 * Category:Chart, diagram and graph formatting and function templates
 * Category:Wikipedia template editors
 * List to table: template and its maintenance category: Category:Articles requiring tables
 * Horizontal TOC: good for country lists in table format.
 * Table: template for specifying table CSS classes such as "wikitable" and "collapsible"
 * Aligned table: for specifying tables as a template, allowing inclusion in other templates and areas where table syntax is problematic.
 * Examples:
 * Chess diagram: chess board template.
 * Goban: Go board template.

Wikimedia sister projects

 * mw:Help:Tables: MediaWiki help page on tables.
 * Wiki markup tables: Meta-Wiki information on tables.
 * m:Help:Sorting: Meta-Wiki information on sortable tables.
 * Table background colors: MediaWiki background colors table.
 * Commons:Chart and graph resources: Chart and graph resources at Commons
 * Commons:Convert tables and charts to wiki code or image files: includes information on converting table markup.
 * Commons:Chart and graph resources: Chart and graph resources at Commons
 * Commons:Convert tables and charts to wiki code or image files: includes information on converting table markup.