Wikipedia:WikiProject Usability/HTML: Difference between revisions
Content deleted Content added
m sp: compatability→compatibility; capitalisation: html |
m rewrite; cleanup |
||
Line 1:
This page needs '''cleanup''', Wiki supports a subset of [[XHTML]], e.g. '''<br />''' instead of '''<br>'''.
Wikipedia allows the use of [[HTML]] directly, and the use of [[Cascading Style Sheets|CSS]] through the <
▲Wikipedia allows the use of [[HTML]] directly, and the use of [[Cascading Style Sheets|CSS]] through the <tt>style="[…]"</tt> and <tt>class="[…]"</tt> elements.
We believe that:
* The use of HTML instead of [[Wiki markup]] is
* If HTML and CSS ''must'' be used, editors should know how to use them properly, with regard to:
** [[W3C]] standards
Line 11 ⟶ 10:
== Why HTML should be used conservatively ==
HTML makes the edit pages hard to read for many users, and on a wiki the readability of the edit page is almost as important as the readability of the page itself, because nobody wants to edit something that they don't understand. ▼
▲HTML makes the edit pages hard to read, and on a wiki the readability of the edit page is almost as important as the readability of the page itself, because nobody wants to edit something that they don't understand.
Occasionally, such as when you are creating notices, and so on (for which there is no markup defined) HTML/CSS must be used.
== HTML and CSS primer ==
HTML is simple to use - just put a pair of tags around some text, e.g. <code><nowiki><em>
Sometimes, however, there isn't any appropriate wikicode for what you want to mark up. In this situation, there are two possible contexts, block and inline. Paragraphs, headings, lists and tables are block elements (they start on a new line), <code><nowiki><b></nowiki></code> & <code><nowiki><i></nowiki></code> are inline elements. In each context, there is a generic HTML element available:
▲HTML is simple to use - just put a pair of tags around some text, e.g. <nowiki><em>italics</em></nowiki>, and it will show up <em>as the tags defined it</em>. Most HTML elements, like bold (strong, b), italic (em, i), list (li), heading (h1, h2...) and even table (table) have their equivalent in the markup, so should be avoided. The CSS, which you can think of as the "display properties" may be added to the markup itself - this is covered later.
*<code><nowiki><span></nowiki></code>: inline
*<code><nowiki><div></nowiki></code>: block
These span and div tags need <code>class</code> or <code>style</code> attributes to change the appearance of the page.
:<code><nowiki><span class="noprint" style="color:red;"></nowiki>red text that does not show up when printed<nowiki></span></nowiki>
▲:<nowiki><span class="noprint" style="color:red">red text that does not show up when printed</span></nowiki>
produces
:<span class="noprint" style="color:red;">red text that does not show up when printed</span>.
Where possible, an appropriate class should be used instead of inline styles, to avoid clutter in the edit window and to be able to change the appearance of, for example, all [[Wikipedia:article message boxes|article message boxes]] at once.
=== List of style properties ===
Before listing properties, you should get to know how to represent certain values:
*Color
*Size can be represented using [[em (typography)|em]], [[percent|%]] and [[pixel|px]], among others.
==== Basic properties ====
''Please note: this page does not want to encourage the use of bright, or non-standard colors. They are used for clearer examples. Please see [[Wikipedia:WikiProject Usability/Color]]''
<!-- you'll note how messy this section looks in the editor, due to all the code -->
* <code>'''
** <
* <code>'''
** <
* <code>'''
▲* '''"background: [color];"''' - 'shorthand' for several background properties, including image. Used for background color
** <
** <
** <
*** You'll note that "transparent" is used for the background here. The standard background
▲* '''"border:''' [thickness] [type] [color];" - the border: color, thickness, type. Type may be solid, outset, dashed, and others
* <code>'''
▲** <tt><nowiki><span style="border: 2px outset cyan; background:yellow;">test</span></nowiki></tt> --> <span style="border: 2px outset cyan; background:yellow;">test</span>
** <
** <
▲*** You'll note that "transparent" is used for the background here. The standard background of wikipedia is #f8fcff, so if you put "white" and neglect the border, you <span style="background:white;">may notice a very slight (but inappropriate) difference in color</span>. Transparent should be used, or no background property should be specified (result is the same).
** <
*** Three values: [top] [right & left] [bottom].
** <
▲* '''"padding: [size];"''' - usually, the "spacing" on the ''inside'' of the border. 1, 2, or 4 sizes may be specified.
▲** <tt><nowiki>foo<span style="border: 1px solid red; padding: 1em;">test</span>bar</nowiki></tt> --> foo<span style="border: 1px solid red; padding: 1em;">test</span>bar
▲** <tt><nowiki>foo<span style="border: 1px solid red; padding: .1em 1em;">test</span>bar</nowiki></tt> --> foo<span style="border: 1px solid red; padding: .1em 1em;">test</span>bar
▲*** Two values: [top/bottom] [right/left].
▲** <tt><nowiki>foo<span style="border: 1px solid red; padding: .1em .5em 1em 2em;">test</span>bar</nowiki></tt> --> foo<span style="border: 1px solid red; padding: .1em .5em 1em 2em;">test</span>bar
***Four values: [top] [right] [bottom] [left] (clockwise).
* <code>'''
** <code><nowiki>foo<span style="border: 1px solid red; margin: 1em;">test</span>bar</nowiki></code> → foo<span style="border: 1px solid red; margin: 1em;">test</span>bar
** <code><nowiki>foo<span style="border: 1px solid red; margin: 3em 1em;">test</span>bar</nowiki></code> → foo<span style="border: 1px solid red; margin: 3em 1em;">test</span>bar
▲* '''"margin: [size];"''' - usually, the "spacing" on the ''outside'' of the border. It's also the distance at which other elements should be "kept away" at. 1, 2, or 4 sizes may be specified, exactly as in "padding". Many browsers will ignore "top/bottom" for margins on ''inline'' elements.
** <
** <
** <
▲** <tt><nowiki>foo<span style="border: 1px solid red; margin: 0em -.3em;">test</span>bar</nowiki></tt> --> foo<span style="border: 1px solid red; margin: 0em -.3em;">test</span>bar
=== List of classes ===
{{main|Wikipedia:Catalogue of CSS classes}}
* syntax: <code>class="<var>class<sub>1</sub></var> <var>class<sub>2</sub></var> …"</code>
*
** <code><nowiki><span class="noprint">This will not show up when printed</span></nowiki></code> → <span class="noprint">This will not show up when printed</span>
== See also ==
|