Help:Cascading Style Sheets: Difference between revisions

Content deleted Content added
No edit summary
Tags: Reverted Visual edit Mobile edit Mobile web edit
Reverted edits by 149.27.3.3 (talk) (AV)
Line 2:
[[Cascading Style Sheets]] allows for flexible formatting of a page. They should be used instead of [[Help:Table|tables]] for non-tabular content whenever possible, because they can be [[Help:User style|manipulated by the reader]] or overridden by an author if your CSS is embedded in another page via a [[Help:Template|template]].
 
== Levels of CSS settings ==
*
Style may be chosen specifically for a piece of content, see e.g., [[Help:Table#Color; scope of parameters|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 core style-sheets===
 
Per skin: [[mw:Gallery of user styles|MediaWiki Manual:Gallery of user styles]] etc.
Typically loaded style sheets:
*[https://phabricator.wikimedia.org/diffusion/SVN/browse/trunk/phase3/skins/common/shared.css common/shared.css]
*[https://phabricator.wikimedia.org/diffusion/SVN/browse/trunk/phase3/skins/common/commonPrint.css common/commonPrint.css]
 
;Skin-specific main file:
e.g., [https://phabricator.wikimedia.org/diffusion/SVN/browse/trunk/phase3/skins/monobook/main.css monobook/main.css] (normal skin for PC's), [https://phabricator.wikimedia.org/diffusion/SVN/browse/trunk/phase3/skins/chick/main.css chick/main.css] (normal skin for handhelds)
 
;Browser-specific fixes (also skin-specific):
Examples for Monobook:
*For Firefox: [https://phabricator.wikimedia.org/diffusion/SVN/browse/trunk/phase3/skins/monobook/FF2Fixes.css monobook/FF2Fixes.css]
*For Firefox:
*For Internet Explorer: [https://phabricator.wikimedia.org/diffusion/SVN/browse/trunk/phase3/skins/monobook/IE60Fixes.css monobook/IE60Fixes.css] [https://phabricator.wikimedia.org/diffusion/SVN/browse/trunk/phase3/skins/monobook/IE70Fixes.css monobook/IE70Fixes.css]
*For Internet Explorer:
*For Opera: [https://phabricator.wikimedia.org/diffusion/SVN/browse/trunk/phase3/skins/monobook/Opera6Fixes.css monobook/Opera6Fixes.css] [https://phabricator.wikimedia.org/diffusion/SVN/browse/trunk/phase3/skins/monobook/Opera7Fixes.css monobook/Opera7Fixes.css] [https://phabricator.wikimedia.org/diffusion/SVN/browse/trunk/phase3/skins/monobook/Opera9Fixes.css monobook/Opera9Fixes.css]
*For Opera:
 
===Site-wide style-sheets===
 
* Site-wide for all skins (desktop view only): [[MediaWiki:Common.css]]
* Site-wide for all skins (mobile view only): [[MediaWiki:Mobile.css]]
* Site-wide per skin: [[MediaWiki:Vector.css]], [[MediaWiki:Monobook.css]], etc.
* Site-wide for user groups: [[MediaWiki:Group-user.css]], [[MediaWiki:Group-autoconfirmed.css]], etc.
* Site-wide for specialist purposes: [[MediaWiki:Print.css]], [[MediaWiki:Noscript.css]], [[MediaWiki:Filepage.css]]
* Site-wide if gadgets loaded: see [[Wikipedia:Gadget]] for more information
 
Note: MediaWiki sites other than English Wikipedia may use <code>MediaWiki:Gadget-site.css</code> instead of MediaWiki:Common.css.
Line 27 ⟶ 40:
===Page-specific style-sheets===
 
Page-specific style-sheets may be introduced through [[Wikipedia:TemplateStyles|TemplateStyles]]. Pages, particularly templates, may also have inline CSS.
 
Some pages have their own CSS, e.g., э[[MediaWiki:FileUploadWizard.css]]
 
===User-specific style-sheets===
 
* Global user-specific for all skins: [[meta:Special:MyPage/global.css]]
* User-specific for all skins: [[Special:MyPage/common.css]]
* User-specific per skin: e.g., [[Special:MyPage/vector.css]], or [[Special:MyPage/skin.css]] for your current skin
* User-specific CSS loaded through JavaScript, e.g., loaded at [[Special:MyPage/common.js]]
* User-specific web-wide browser settings: local file referred to in the browser settings, or directly set in the browser
 
Line 43 ⟶ 56:
===Usage===
 
An HTML element may be just taken from the wikitext (see [[Help:HTML in wikitext|HTML in wikitext]]), e.g., span, or the result of translating wikitext, e.g., the <code><nowiki>'''</nowiki></code> code is changed into <nowiki><b></nowiki>, 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.
Line 49 ⟶ 62:
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 [http://www.w3.org/TR/REC-CSS2/cascade.html cascade].
 
== Supported elements ==