Help:Cascading Style Sheets: Difference between revisions

Content deleted Content added
m syntaxhighlight
Reverting edit(s) by 102.45.18.254 (talk) to rev. 1297657178 by Annh07: Unexplained content removal (UV 0.1.6)
 
(25 intermediate revisions by 17 users not shown)
Line 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><{{tag|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 73:
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 <nowiki><{{tag|div></nowiki>}} element with a green border and its contents floated to the right would be created with
<syntaxhighlight lang="html">
<div style="float:right; border:thin solid green;">
Line 89:
Some wikitext elements allow you to insert CSS styling directly into them. An example is the table syntax:
{{-}}
<syntaxhighlight lang="wikitext">
<pre>
{| style="your style here"
|-
|your table stuff
|}
</syntaxhighlight>
</pre>
{{Further2|[[Help:Tables]]}}
 
Line 113:
One extreme "style" for a text is not displaying it, with
 
<syntaxhighlight lang="css">
.''classname'' {display: none}
#.''idclassname'' {display: none}
.#''classnameid'' {display: none}
</syntaxhighlight>
 
etc.
Line 126 ⟶ 128:
=== Non-print ===
 
One can exclude content from being printed (if the browser supports CSS) by declaring the content to be of the "noprint" class:
<syntaxhighlight lang="html">
<div class="someclass noprint">This will not appear in the print version.</div>
Line 156 ⟶ 158:
=== Variable class or id ===
 
A class or id can depend on the result produced by a template or on a template parameter, e.g. <syntaxhighlight lang="moinwikitext" inline>class="abc{{{1|def}}}"</syntaxhighlight>". 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. <syntaxhighlight lang="moinwikitext" inline>class="abc{{{1}}}"</syntaxhighlight>" 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.