Wikipedia:WikiProject Usability/HTML: Difference between revisions
Content deleted Content added
+link to article on meta |
nav menu |
||
(16 intermediate revisions by 13 users not shown) | |||
Line 1:
{{cleanup|date=November 2010}}
{{Wikipedia:WikiProject Usability/Navigation menu | Miscellaneous}}
Wikipedia allows the use of [[HTML]] directly, and the use of [[CSS]] through the <tt>style="[…]"</tt> and <tt>class="[…]"</tt> elements. ▼
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 <
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
** Cross-browser
== 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><
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><i>italics</i></nowiki>, and it will show up <i>as the tags defined it</i>. Most HTML elements, like bold (strong, b), italic (em, i), list (li), heading (h1, h2...) and even table (table) have their equivelant in the markup, so should be avoided. The CSS, which you can think of as the "display attributes" 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>
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.
However, when you ''must'' use inline styles, you can do this. They take the following form: <code>style="<var>p</var>: <var>v</var>; <var>p</var>: <var>v</var>; <var>…</var>"</code>, where <var>p</var> is a property and <var>v</var> the value you want to assign to that property.
▲:<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>.
▲=== List of style attributes ===
*Color
*Size can be represented using [[em (typography)|em]], [[percent|%]] and [[pixel|px]], among others.
▲Before listing attributes, you should get to know how to represent certain values:
''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:
▲*Color may be represented using hex form (#000000 being black, #ff0000 being red, for example), or using names (red, green...)
▲==== Basic attributes ====
▲''Please note: this page does not 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 innapropriate) difference in color</span>. Transparent should be used, or no background attribute 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>
*
** <
== See also ==
* [[meta:Help:HTML in wikitext]]
[[Category:WikiProject Usability|HTML]]
|