Help:Cascading Style Sheets

Cascading Style Sheets allow for flexible formatting of a page. They should be used instead of tables for non-tabular content whenever possible, because they can be manipulated by the reader or overridden by an author if your CSS is embedded in another page via a template.

Levels of CSS settings
Style may be specified specifically for a piece of content, see e.g. color; scope of parameters Alternatively, style is specified for CSS selectors, expressed in terms of elements, classes and id's. This is done on various levels:

Author style sheets, in this order:

Note: See WP:CLASS for a list of all the style sheets loaded.


 * MediaWiki in general, per skin: MediaWiki Manual:Gallery of user styles etc. Typically loaded style sheets:
 * common/shared.css
 * common/commonPrint.css
 * Skin-specific main file, e.g. monobook/main.css (normal skin for PC's), chick/main.css (normal skin for handhelds)
 * Browser-specific fixes (also skin-specific). Examples for Monobook:
 * For Firefox: monobook/FF2Fixes.css
 * For Internet Explorer: monobook/IE50Fixes.css monobook/IE55Fixes.css monobook/IE60Fixes.css monobook/IE70Fixes.css
 * For Opera: monobook/Opera6Fixes.css monobook/Opera7Fixes.css monobook/Opera9Fixes.css
 * Browser-specific fixes (not skin-specific):
 * For Internet Explorer: common/IE80Fixes.css
 * Site-wide for all skins: MediaWiki:Common.css
 * Site-wide per skin: MediaWiki:Monobook.css, MediaWiki:Chick.css, etc.
 * User-specific for all skins: Special:Mypage/common.css
 * User-specific per skin: Special:Mypage/skin.css (note that in CSS terminology, the user-specific style sheets are not user style sheets)

User style sheet:


 * Web-wide, user-specific: local file, referred to in the browser settings, or directly set in the browser

A HTML element may be just taken from the wikitext (see HTML in wikitext), e.g. span, or the result of translating wikitext, e.g. the  code is changed into , or part of the code for the skin.

A class may be produced by the software, e.g. ns-namespace number for the HTML-element "body", and extiw for an interwiki link in the page body, or taken from the wikitext.

Similarly an id may be produced by the software, e.g. bodyContent, or taken from the wikitext.

In the case of conflicting style settings for a piece of content, the resulting setting depends primarily on the indication "!important". Secondarily, if both are important, the user wins, if neither is, the author wins. Tertiarily it depends on specificity. Only lastly it depends on order between and within style sheets: the last wins. Thus a User:username/monobook.css does not win from MediaWiki:Monobook.css (both author, not user) if the specificity of the latter is greater. See also cascade.

Supported elements
MediaWiki supports most CSS, with such exceptions as the url attribute. There were some bugs in CSS support in earlier versions.

CSS in wikitext
You can use CSS styling in HTML elements in your code (see Help:HTML in wikitext for a list of elements supported by MediaWiki) like you would in normal HTML markup.

For example, a  element with a green border and its contents floated to the right would be created with Here comes a short paragraph that is

contained in a "div" element that is

floated to the right. Here comes a short paragraph that is

contained in a "div" element that is

floated to the right. which would produce the box to the right. Some wikitext elements allow you to insert CSS styling directly into them. An example is the table syntax:

MediaWiki existing styles
You may wish to use a style type that is already predefined by MediaWiki, or the site that you are visiting. You can also create a style that is unique to your page.

Vector is the default style, you can view it at: http://en.techinfodepot.info/skins-1.5/vector/main-ltr.css

You will give your CSS tag an existing "class"

Please put a list of existing classes here.

Non-display
In an embedded page, one can hide comments in one version, and show them in another view. 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.

To view hidden text, download the Web Developer Toolbar for Firefox here, then choose Misc. -> show hidden elements in that toolbar. It will make all hidden elements appear.

Non-print
One can exclude content from being printed (if the browser supports CSS) by declaring the content to be of the "noprint" class: This will not appear in the print version.

Major style blocks

 * column-content - overall space within the margins of which the content exists.
 * firstHeading - the class of the heading tag at the top of every page
 * contentSub - the name of the wiki immediately underneath the main heading, but above the body text
 * content - the white background, thin bordered box which contains the main page content.
 * bodyContent - the main page content within the content box

The portlet class is the style used by all the div blocks around the main content. Identified blocks using that class:
 * p-cactions - id for the list of page-related tabs above the main content (page, talk, edit, etc.), top.
 * p-personal - id for the list of user-related links above the main content (username, talk, etc.), top.
 * p-logo - id for the block that contains the logo, top left.
 * p-navigation - id for the block that contains the navigation links on the left of the page
 * p-search - the block that contains the search buttons
 * p-tb - the block that contains the toolbox links
 * p-lang - the block that contains interlanguage links

The footer at the bottom of the page includes blocks with the following ids
 * footer - overall footer container block
 * f-poweredbyico - the powered by MediaWiki image that normally resides to the right of the page
 * f-list - id for the list that contains all the bits of text at the bottom of the page

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 style parameter value
Wikitext like Wed displays "Wed" if parameter 3 is defined, but its value is 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.

TechInfoDepot-specific help
Please see TechInfoDepot:Catalogue of CSS classes and classes used in microformats