Jump to: navigation, search
This page is a translated version of the page Manual:CSS and the translation is 34% complete.

Other languages:
Deutsch • ‎English • ‎British English • ‎español • ‎français • ‎italiano • ‎日本語 • ‎polski • ‎português • ‎português do Brasil • ‎中文

Cascading style sheet (CSS) rules sets much of the look and feel of MediaWiki: font size, colors, spacing, the logo and background image, even whether site content is displayed or is hidden.

CSS can be used to change the style of the entire wiki, for example to make the background a different color, or you can use inline CSS to style specific pieces of text in your wiki. For example green text can be accomplished by doing <span style="color:green;">green text</span>. If you want to make all text on the wiki larger you can add the code body { font-size: larger; } to MediaWiki:Common.css.

Pour changer l'apparence et la sensation de l'affichage de votre MediaWiki (Comment il se voit dans votre navigateur), vous pouvez mettre le CSS dans MediaWiki:Common.css.

Note Note : Si le code ajouté à MediaWiki:Common.css ne prend pas effet immédiatement, vous pourriez avoir à faire un hard refresh. (Rafraichissement de votre page)

Pour changer la façon dont les pages de MediaWiki s'affichent à "l'impression", vous pouvez mettre du CSS dans MediaWiki:Print.css sur votre wiki

If enabled on your wiki, individual users can create custom stylesheets just for themselves at Special:MyPage/<skin_name>.css (for example Special:MyPage/vector.css if they are using the vector skin). Special:MyPage/common.css allows the creation of personal stylesheets for all skins.

You can also create custom skins for MediaWiki.


La syntaxe CSS, les attributs et les valeurs, doivent être corrects sinon cela ne fonctionnera pas correctement. World Wide Web Consortium (W3C) est une excellente référence pour vérifier que le code CSS est rédigé correctement, en accord avec les standards:

Wikipédia donne un bon aperçu du CSS.

If you prefer an easily consumable reference alongside demos of CSS features Mozilla Developer Network CSS Reference will provide you an "up-to-date" guide to syntax and basic usage of the various elements.


Be sure to keep your HTML markup semantic. Relying on styling to indicate meaning is a bad practice (e.g. for machine readability such as by search engines, screen readers using text-to-speech, and text browsers).

Normalized CSS[edit]

Much CSS today relies on a "reset" or "normalize" CSS to make all browsers work the same. MediaWiki does not have a reset per se, though there are built-in stylesheets such as common/commonElements.css, common/commonContent.css, common/commonInterface.css, and MediaWiki:Common.css.

If you copy CSS, watch if it depends on additional CSS.

For example jsFiddle has a checkbox for "Normalized CSS". This sets margins to 0 and resets the numbers on ordered lists. Since none of this normalization CSS is running on MediaWiki sites, you should not use it when testing MediaWiki-related code.

jsfiddle has a feature to import CSS. If you're testing against the Vector skin on English Wikipedia, the primary sheets should be (in this order):

You can adjust the domain in the URL for other WMF wikis. By importing these, you can get a better idea how your CSS interacts with the CSS on WMF wikis.

Les styles ne fonctionnent pas sur Special:UserLogin ou Special:Preferences?[edit]

Par défaut, les customisations CSS du site (ex. MediaWiki:Common.css) ne prend pas effet sur la page de login et des préférences This is to preserve the security of the login process, and to allow users to remove any unwanted customizations without being interfered with. If you are not concerned about the security risks, you can use the $wgAllowSiteCSSOnRestrictedPages configuration setting to allow custom CSS to work on these pages.

Voir aussi[edit]