If you want to shape tables with wikitext, you have plenty of options. This one page won't go into them all, but it will show you how wikitext matches up to HTML markup, the difference a CSS class makes, and an example of a simple table that works on both desktop and mobile devices.

Basic table code

Wikitext is, in many ways, just shortcut for HTML. If you're familiar with HTML, you probably already know how to build a wikitext table. Here's a chart that will help you understand the connection between wikitext and HTML:

Description You type
Begin table
(equivalent to <table>)
Begin table row
(equivalent to <tr>)
Table header (part of a row; equivalent to <th>) ! or !!
Table cell (part of a row; equivalent to <td>) | or ||
End table
(equivalent to </table>)

Fandom's default CSS classes

Deep within Fandom's code lie two classes that you can put at the very start of your table. No matter which wiki you're on, there is always some default formatting for .article-table and .wikitable. If you use VisualEditor, .article-table will be automatically added so that the basic structure of your table will be:

{| class = "article-table"

But there are cases where you might consider using .wikitable or no class—instead. Here's what they all look like on a completely un-customized wiki:

With .article-table you get a lighter design

On UCP wikis, .article-table looks a little different, giving all cells the same background

With .wikitable you get greater definition for each cell

Without a CSS class, you get neither borders nor header backgrounds

If you are styling tables with CSS customization, it is often best to target the .article-table class to style tables already using the class, as this one is the default.

Technically, another default table class exists at Fandom, called .WikiaTable. However, if unaltered by local CSS declarations, it provides precisely the same styling as .article-table

Basic tables

As explained elsewhere, tables don't always display well on mobile web.

The best approach is to keep things as simple as possible. Look at the following wikitext, and then notice, on your phone, how the table works on that smaller display:

{| class = "article-table"
!Rank 1
!Rank 2
!Rank 3
|Page A
|Page B
|Page C

...which gives:

Page Rank 1 Rank 2 Rank 3
Page A 1 2 3
Page B 1 2 3
Page C 2 3 4

More advanced table coding

Tables can be made significantly more advanced than the example above. If you want to explore other options for wikitext tables, you could start by consulting the MediaWiki help page for tables. But remember that much of what you'll see in places like mediawiki.org or Wikipedia's help page don't really consider the effects of tables in mobile. It's important to always check your work with tables on an actual phone to see how well it displays for the many mobile readers of your wiki.

It is also possible, in some specific use cases where data needs to be calculated, to use templates or even to use Lua-based templates, both to create pre-existing table structures, or to use templates within cells.

See also

Further help and feedback

Community content is available under CC-BY-SA unless otherwise noted.