FANDOM


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 codeEdit

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. You just may not know it yet. 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 Edit

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 either the VisualEditor or the classic editor's visual mode, .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:

Article-table

With .article-table you get a lighter design

Wikitable

With .wikitable you get greater definition for each cell

No table class

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

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 tablesEdit

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"
!Page
!Rank 1
!Rank 2
!Rank 3
|-
|Page A
|1
|2
|3
|-
|Page B
|1
|2
|3
|-
|Page C
|2
|3
|4
|}

...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 Edit

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.

See alsoEdit

Further help and feedbackEdit