Help:User style

The user can customize fonts, colors, positions of links in the margins, and many other things! This is done through custom Cascading Style Sheets stored in subpages of the user's "User" page.

E.g. To create your own CSS modifications for the default Vector skin, create a page at Special:Mypage/vector.css containing the CSS you want to use. For how to hide particular messages, see WQ:CSSHIDE.

General
Note: In the default configuration, any User Style code will be ignored. To enable User Style, the following two settings have to be enabled through LocalSettings.php:

For each user-definable style, a skin is first selected, and a corresponding Cascading Style Sheet (CSS). For each skin, the user can make various choices regarding fonts, colors, positions of links in the margin, etc. CSS is specified with reference to selectors : HTML elements, classes and id's specified in the HTML code. Accordingly, what the possibilities are for each skin can be seen by looking at the HTML source code of a page, in particular looking at these classes and id's: the more there are, the more versatility there is.

The defaults for all skins are in MediaWiki:Common.css. Other CSS pages are separate per skin. For example, in the English WikiQueer the defaults are in


 * http://en.WikiQueer.org/style/monobook/main.css and MediaWiki:Monobook.css
 * http://en.WikiQueer.org/style/wikistandard.css and MediaWiki:Standard.css
 * http://en.WikiQueer.org/style/cologneblue.css and MediaWiki:Cologneblue.css
 * http://en.WikiQueer.org/style/nostalgia.css and MediaWiki:Nostalgia.css

and on Meta, the defaults are:


 * http://meta.wikimedia.org/style/monobook/main.css and m:MediaWiki:Monobook.css
 * http://meta.wikimedia.org/style/wikistandard.css and m:MediaWiki:Standard.css
 * http://meta.wikimedia.org/style/cologneblue.css and m:MediaWiki:Cologneblue.css
 * http://meta.wikimedia.org/style/nostalgia.css and m:MediaWiki:Nostalgia.css
 * MediaWiki:Myskin.css

The files in the style directory are for a given skin probably the same in each project. The name of the style directory is set on installation, see mw:Manual:LocalSettings.php.

In the monobook skin, you can change any aspect of the UI specified in http://en.WikiQueer.org/style/monobook/main.css and MediaWiki:Monobook.css or similar using your own JavaScript or CSS. The changes are in subpages of your user page, which, e.g. for Monobook on this project, can be reached through the links Special:Mypage/monobook.css and Special:Mypage/monobook.js.

Also you can change the classic skin; your subpages should be named User:username/ standard.css and User:username/ standard.js (and similar for the other skins).

Just enter some css/js in that page. The preview of JS does not work, and that of CSS works in a special way: it allows viewing of the margins of the page (not the contents) on the basis of the style info in the page, provided that the skin used is the skin for which the page applies. This has limitations. E.g., one can preview how links in the margin will look, but these may not be of all the types one would want to check. After saving, while still on the page or while on any other page, do a forced reload (shift-reload/ctrl-f5) to get the new files.

The HTML source contains lines like

for the project-wide CSS for the particular skin (in this case here on WikiQueer referring to /style/wikistandard.css ) and the personal JS and CSS for a particular skin.

Thus the server provides HTML referring to the CSS and JS files, but it does not do any interpretation of their content. Hence, for example, a is not interpreted as a link. The interpretation is done by the browser, depending on its capabilities and settings.

For "MySkin" there is no main.css applicable. The applicable personal css page is User:username/ myskin.css (all lowercase!).

CSS in user subpages vs. css in a local file
In addition to the above, or alternatively, a local CSS can be set on the browser. If one uses multiple browsers, each can be set to a different CSS. Each applies to the whole world wide web, not just a MediaWiki project (and does not depend on being logged in). However, a setting only affects other webpages if they use the same CSS selector; e.g. a setting for the selector a.extiw affects fewer pages on the web than one for h2 (but it affects at least all MediaWiki projects, not just one).

For lines of CSS which should be different on different MediaWiki projects, e.g. for a different background color for easy distinction, clearly the local CSS cannot be used; at least these lines should be put in the user subpages.

Some computers, e.g. in internet cafes, mobile devices/tablets, do not allow users to set preferences for the browser. In that case the user subpages allow the setting of a user style anyway.

When the browser has been set to the option to ignore the font size specified in the webpage or external CSS, CSS lines regarding font size have to be put in the local CSS.

CSS selectors
The CSS selectors, expressed in terms of elements, classes and id's, relevant for the style of the page body include the following. As far as possible, examples are given, which show the result for the current style settings:


 * &#58;link — links — example: Help:Index ; default: help:index (See a vs :link)
 * &#58;link:link
 * &#58;link:visited
 * &#58;link#contentTop
 * &#58;link.external — http://example ; default:  http://example
 * &#58;link.extiw – interwiki link in page body - ; default: en:example
 * &#58;link.image – link from full image to image description page
 * &#58;link.internal – link to file itself (Media:), and links from thumbnail and magnifying glass icon to image description page (note that color and font size specified for a.internal are only applicable in the first case)
 * &#58;link.new example ; default: example


 * .allpagesredirect - abc - redirects in Special:Allpages and Special:Prefixindex
 * body.ns-0, ..., body.ns-15 (namespaces)
 * div#bodyContent
 * div#column-content
 * div#editsection
 * div#globalWrapper
 * div#tocindent
 * div.tocline
 * h1.firstHeading
 * h2
 * h3
 * img.tex TeX image
 * small - example
 * table.toc

 a vs :link - It's a common mistake to use " " instead of " " to style links. Whereas " " applies only to links, " " applies to both links and named anchors (e.g. ).

Normal internal links are not in class internal (they used to be, and still are on sites that use an older version of the software, e.g. ); they can be styled referring to :link and :link:visited, in general, after which styling of :link.extiw etc. can provide for exceptions to this general style for links.

For interlanguage links:


 * #p-lang a

One may also have the style depend on the value of an attribute, e.g. with the selectors:


 * &#58;link[title ="User:username"]
 * &#58;link[title ="pagename"]
 * &#58;link[href ="full url "]

to color-code or highlight particular users (including oneself) and/or links to particular pages (like the bolding of watched pages on Recent Changes). This works in Opera, but not in IE. See also Help:Watching pages.

The watchlist and Recent Changes use two classes:


 * autocomment example
 * new (see below)

The page history has classes autocomment and:


 * user
 * minor

Thus the font specified for user applies in the page history, but not in the watchlist or Recent Changes.

Edit page
example1 example2
 * Edit box: textarea#wpTextbox1
 * Edit summary box: input#wpSummary

Major style blocks
''See meta:Customization:Explaining_skins

Non-display
One extreme "style" for a text is not displaying it, with

.classname {display: none}
 * 1) id {display: none}

etc.

Non-displayed links do not work (as opposed to links in a very small font).

It cannot be used to remove text in expressions for template names, parameter names, parameter values, page names in links, etc.

Variable class or id
A class or id can depend on the result produced by a template or on a template parameter, e.g. class="abc ". For one or more of the possible class names the style of that class can be defined. If the class is undefined it is ignored, so the standard style is used.

In the simplest case we have e.g. class="abc " and define class abcdef. If the parameter value is "def" it applies.

If a page for general use only makes sense when styles are defined for certain classes, then these have to be specified in the page MediaWiki:Common.css, which applies for all users and all skins, as far as not overridden.

Variable HTML attribute name
An HTML attribute name can be made variable. HTML Tidy removes attributes with invalid names at the server side, so the result does not depend on a browser capability to ignore invalid attribute names, and the amount of data sent is reduced. For a variable with possible value "class", see Infobox.

Variable style parameter value
Wikitext like Wed displays "Wed" if parameter 3 is defined, but not "none", and displays nothing if parameter 3 is undefined or "none". If the value of parameter 3 is a display style other than "none", that style is applied.

Samples
/* make the background behind the content area and the tabs a light grey */
 * 1) content, #content table
 * 2) p-cactions ul li a { background: #f5f5f5; }

/* stop background image from scrolling with content area */ body { background-attachment: fixed; }

/* replace the book in the background with something else */ body { background: Purple; }

/* changes the background of pre areas */ pre { background: White }

/* don't use any logo, move the boxes onto that area instead */
 * 1) p-logo { display: none }
 * 2) column-one { padding-top: 0; }

/* suppress the person icon by your username */ li#pt-userpage { background: none }

/* use browser prefs for text size and font */ html, body, #globalWrapper { font: inherit !important; }

/* always underline links */
 * link { text-decoration: underline; }

/*Display body content in a narrower column for easier reading*/ /*adjust percentages as desired*/ div#bodyContent { width: 50%; line-height: 105%; }

/* change background of unselected tabs */
 * 1) p-cactions ul li a { background: #C7FDC7; }

/* change background of selected tabs */
 * 1) p-cactions ul li.selected a { background: white; }

/* change border background of selected tabs */
 * 1) p-cactions li.selected { border-color: #aaaaaa; }

/* tab bottom not removed on hover */
 * 1) p-cactions li a:hover { z-index: 0; text-decoration: none; }
 * 2) p-cactions li.selected a:hover { z-index: 3; }

/* style the search box and the buttons below it */ input.searchButton { background-color: #efefef !important; border: 1px outset !important; }
 * 1) searchInput { border: 1px inset !important; }

/* standard link colors */ a:link { color: #0645ad !important; } a:visited { color: #0b0080 !important; } a.new:link { color: #cc2200 !important; } a.new:visited { color: #a55858 !important; } a.extiw:link { color: #3366bb !important; } /* links to other WikiQueers */ a.extiw:visited { color: #3366bb !important; } a.external:link { color: #3366bb !important; } /* external links */ a.external:visited { color: #3366bb !important; }

/* put scrollbar on pre sections instead of ugly cutoff/overlap in firefox */ pre { overflow: auto; }

/* strikeout Upload File link as a reminder to upload to Commons instead */ li#t-upload { text-decoration: line-through; }



Rounded corners in Mozilla
/* make a few corners round, only supported by moz/firefox/other gecko browsers for now */ -moz-border-radius-topleft: 1em; -moz-border-radius-topright: 1em; } -moz-border-radius-topleft: 1em; -moz-border-radius-bottomleft: 1em; } div.pBody { -moz-border-radius-topright: 1em; -moz-border-radius-bottomright: 1em; }
 * 1) p-cactions ul li, #p-cactions ul li a {
 * 1) content {

/* same following the css3 draft specs, any browsers supporting this? */ border-top-left-radius: 1em; border-top-right-radius: 1em; } border-top-left-radius: 1em; border-bottom-left-radius: 1em; } div.pBody { border-top-right-radius: 1em; border-bottom-right-radius: 1em; }
 * 1) p-cactions ul li, #p-cactions ul li a {
 * 1) content {

Rounded Corners in Chrome and Safari (webkit browsers)
/* rounded corners for webkit browsers: works on Chrome v5.0.307.11 beta and Safari v4.0.4 */ -webkit-border-top-left-radius: 8px; -webkit-border-top-right-radius: 8px; } -webkit-border-top-left-radius: 8px; -webkit-border-bottom-left-radius: 8px; } div.pBody { -webkit-border-top-right-radius: 8px; -webkit-border-bottom-right-radius: 8px; }
 * 1) p-cactions ul li, #p-cactions ul li a {
 * 1) content {

Rounded corners/tabs links

 * Moz: see the rules above
 * http://www.vertexwerks.com/tests/sidebox/ -- sidebox formatting
 * http://www.alistapart.com/articles/slidingdoors2/ -- rounded tabs with rollover effect
 * http://www.alistapart.com/articles/customcorners/ -- another variant for rounded box corners
 * http://alistapart.com/articles/customcorners2/, Demo of this
 * http://www.alistapart.com/articles/mountaintop/ -- even weirder corner variants
 * http://www.virtuelvis.com/gallery/css/rounded/ -- simple freestyle variant using the :before and :after pseudo-elements (only css2 browsers, not in IE)

Print view tweaks
/*
 * Place all print-specific rules in an @media print block.

/* save ink and paper with very small fonts */ @media print { #footer, #content, body { font-size: 8pt !important; } h1 { font-size: 17pt } h2 { font-size: 14pt } h3 { font-size: 11pt } h4 { font-size: 9pt } h5 { font-size: 8pt } h6 { font-size: 8pt; font-weight: normal; } }

/* Advanced things: using :before and :after it's possible to add formatting this here adds the full href of a link after it (not needed in the current version): */ @media print { #content a:link:after, #content a:visited:after { content: " ( " attr(href) " ) "; } }

Make the user toolbar a sidebox
Tested to work in Camino, Safari and Internet Explorer 7. /* Transform the user toolbar into a sidebox */ position:relative; z-index:3; width: 11.6em; }
 * 1) p-personal {

width: 10.7em; border: none; margin: 0 0 0.1em 0em; float: none; overflow: hidden; font-size: 95%; background: White; border-collapse: collapse; border: 1px solid #aaaaaa; padding: 0 0.8em 0.3em .5em; }
 * 1) p-personal .pBody {

line-height: 1.5em; list-style-type: square; list-style-image: url("/style/monobook/bullet.gif");
 * 1) p-personal ul {

font-size:95%; margin: 0 0 0 1.5em; padding:0; text-align:left; text-transform: none; }

display: list-item; padding:0; margin: 0 0 0 0; margin-bottom: 0.1em; }
 * 1) p-personal li {

/* suppress the person icon by your username */ /* needed if not already in place */ li#pt-userpage { background: none } See the monobook main.css for the full styles in use by default.

Fix the sidebar's position while you scroll
In the default Vector skin, the sidebar’s position can be fixed easily:

/* Fix sidebar */ div#mw-panel { position: fixed; overflow: auto; top: 0px; bottom: 0px; height: 100%; /* Prevent content overlay when sidewards scrolling */ background-color: #F6F6F6; border-right: 1px solid #A7D7F9; } /* Prevent sidewards scrolling in pre elements */ pre { overflow: auto; max-height: 25em; }



The Cologne Blue skin has an option for a "floating left" quickbar, which causes the navigation links and toolboxes and such to stay in the same position on the screen while you scroll. This provides the same functionality for the Monobook skin (in Mozilla). See meta:Help:User style/floating quickbar.

Moving category links
Moves category links in the upper right corner of content area, and paints them gray.

/******************************************************************/ /* moving catlinks to the right                                  */ /******************************************************************/

/* move the catlinks box */ position:absolute; z-index:1; /* border: 1px solid #aaaaaa; background: #fafaff; */ right:1em; top:-0.25em; width:10.5em; float:right; margin: 0.2em; padding:0.2em; }
 * 1) catlinks {

/* format the catlinks itself */ p.catlinks { color: #aaaaaa; font-family: Verdana,sans-serif; font-size:67%; line-height: 1.5em; text-align:left; text-indent:0; text-transform: none; white-space:normal; margin: 0.2em; }

display: inline; }
 * 1) p-personal h5 {

/* format links in the catlinks (as distinguished from ":" and "|") */ p.catlinks a { color:#888888; }

Diff view styling
/* don't use a smaller font */ td.diff-addedline, td.diff-deletedline, td.diff-context { font-size: 100% };

/* underline just the text that's different */ span.diffchange { text-decoration:underline; }

External links on css

 * http://www.csszengarden.com/ -- inspiration
 * http://css-discuss.incutio.com/ -- highly concentrated info, very comprehensive
 * http://www.alistapart.com/ -- great articles
 * http://www.positioniseverything.net/ -- some entertaining ie bugs and more
 * http://meyerweb.com/eric/css/edge/ -- great ideas for advanced css

JavaScript
JavaScript has many possibilities, for example adding text, including links, at the desired positions. This added content may depend on content on the HTML source page produced by the server; for example it may depend on HTML elements with an ID, by applying getElementById. The position of insertion may be specified by insertBefore.

System requirements
User JavaScript customization requires that your wiki administrator sets a configuration variable in LocalSettings.php:

$wgAllowUserJs = true;

As of MediaWiki 1.6.3 if you customize a user JavaScript page such as monobook.js there is no warning message displayed in the case where the WikiQueer is configured to disable user JavaScript. Apparently the best method to determine this is to check your MediaWiki server's LocalSettings.php if you have the access rights to do this, or experiment with adding some custom JavaScript to see if it works. The Firefox Web Developer's extension contains an "information | view JavaScript" function which makes it convenient to check what JavaScript Firefox has loaded or not loaded. The main English WikiQueer site is configured with user JavaScript enabled.

Changing access keys
These are now defined/set from js, you can easily customize them by changing some elements in the 'ta' array (see ). Example line: ta['ca-nstab-main'] = new Array('c','View the content page'); The access key is the first value in the array. An example which changes this accesskey to '0': ta['ca-nstab-main'] = new Array('0','View the content page'); Since alt-d is also a shortcut to the address bar in most browsers, you might want to disable the alt-d shortcut for Delete, by entering an empty string as access key this way: ta['ca-delete'] = new Array('','Delete this page'); Finally, to disable all access and tooltips drop ta = false; in your monobook.js.

The site's global access keys are in corresponding JavaScript for the skins. For example, the keys for Monobook are in the (protected) page MediaWiki:Monobook.js.

To disable or change the global access keys for the 'power user editing shortcuts', you must edit the six (protected) pages starting with the Accesskey prefix in the MediaWiki namespace.

Moving categories to top
The following code moves the category box to the top of the article. Of course, you might want to apply some CSS to make it look prettier:

function catsattop { var cats = document.getElementById('catlinks'); var bc = document.getElementById('bodyContent'); bc.insertBefore(cats, bc.childNodes[0]); }

An alternative that, when coupled with an appropriate stylesheet, will put the text up at about the same line as the title:

function categoryToTop { var thebody = document.getElementById('contentTop'); var categories = document.getElementById('catlinks');

if (categories != null) { categories.parentNode.removeChild (categories); thebody.parentNode.insertBefore(categories, thebody); } }

Some CSS to go with that...

/* move the catlinks box */ right:1em; top:-0.25em; max-width: 50%; /* this limits the box size, but doesn't set strictly */ float: right; margin: 0.5em; padding: 0.2em; }
 * 1) catlinks {

/* format the catlinks itself */ p.catlinks { font-size:67%; text-align:left; text-indent:0; text-transform: none; white-space:normal; margin: 0.2em; }

Unfortunately, if the category box is large (such as on entries on U.S. presidents and other major figures), it can push an infobox off to the side. To correct this, the "clear: right" attribute can be added to an infobox.

Wikitext-controlled CSS
CSS can be controlled through JS by wikitext. For example, an HTML element "span" without content can, through its class and id, provide parameters for JS specifying CSS for any parts of the page. For example, if a page contains a "span" element with class FA and id lc, MediaWiki:Monobook.js specifies the style and title of elements "li" of class interwiki-lc, thus controlling the style and title of the interlanguage link of language code lc in the margin, provided that the skin specifies this class interwiki-lc (E.g., Cologne Blue specifies class='external' for each language, so it does not work for that skin.) See also Link FA.

External links on JS

 * http://www.quirksmode.org/ -- see the JavaScript and DOM section
 * http://www.alistapart.com/
 * http://www.quirksmode.org/dom/domform.html -- form cloning (might be possible to upload a few images at once using this, also a good starting point for the structure cloning)