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?

5 Answers 5



#toc { float: right };

to your MediaWiki:Common.css wiki page.


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.

  • Great. I also suggest adding margin (style="float:right;margin-left:40px") so that there is some distance between TOC frame and actual content (looks better this way) Commented Mar 22, 2019 at 13:07

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

{| align="right"
| __TOC__
  • This has no effect on the TOC for me, although Arlen's div solution works.
    – Sparr
    Commented Feb 10, 2014 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
    Commented Dec 15, 2014 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.


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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