Web Applications Stack Exchange is a question and answer site for power users of web applications. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

According to the MediaWiki FAQ

A TOC is added automatically as soon as you have more than three headers.

which is fine and all, but I'd like it floated to the right, so that it does not take up a lot of vertical space at the top of the page.

How can I float the table of contents to the right?

share|improve this question
up vote 6 down vote accepted


#toc { float: right };

to your MediaWiki:Common.css wiki page.

share|improve this answer
Brilliant! Thank you. – Robert Munteanu Jul 16 '10 at 10:46
For any noobs out there (like me), you can access this special page just like any other, with an URL like this: my.domain.com/MediaWiki/index.php?title=MediaWiki:Common.css – user35512 Mar 3 '13 at 5:41
...or by writing the name to site's search box. – che Mar 5 '13 at 11:30

For one page use

<div style="float:right;">__TOC__</div>

This is what I usually do. Being that I do a lot with styling and so forth, I hate using my user css to modify anything since then I don't see what everyone else sees and therefore don't know what a visitor will see.

share|improve this answer

If you just want to do it for one particular page and not all pages the following WikiMarkup should work (source):

{| align="right"
| __TOC__
share|improve this answer
This has no effect on the TOC for me, although Arlen's div solution works. – Sparr Feb 10 '14 at 14:28
This does not work after Mediawiki 1.19, but works before. Use Arlen's solution instead: <div style="float:right;">__TOC__</div> – elomage Dec 15 '14 at 9:13

Try using this in the Mediawiki:common.css file

#toc {float:right;margin:0 0 1em 1em;position:fixed;top:150px;right:10px;};

This not only places the floating TOC to the right, but also keeps it visible all the time while scrolling up and down the page.

share|improve this answer

What exactly I have done to accomplish this:

  1. In the search box, type "MediaWiki:Common.css"
  2. You will see the MediaWiki:Common.css page that you can now "Create" if you have never made any modifications to id, or "Edit" if you have already created it.
  3. Add the following code: #toc {float:right;margin:0 0 1em 1em;position:fixed;top:150px;right:10px;}; and Save your changes.
  4. Make sure to clear your cache.
  5. Load a page with a Table of content

Thank you for pencilslate code.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.