MediaWiki User Guide/Text Formatting
From Wikibooks, the open-content textbooks collection
The following is an overview of text formatting available in Mediawiki:
| Formatting | Markup | Note |
|---|---|---|
| Boldface | '''text''' |
|
| Italics | ''text'' |
|
| Boldface and italics | '''''text''''' |
|
| Boldface combined with wikilink | '''[[text]]''' |
The reverse order of ticks and brackets does not work: [['''text''']] |
Other text formatting such as underline or blockquote needs to be done using HTML tags, including U for underline, TT for typewriter text, S for strikethrough, SUB for lower index and SUP for upper index.
[edit] HTML
Text formatting can also be done using HTML and CSS. Some of the most useful HTML elements are:
| Task | Markup | Note |
|---|---|---|
| Preformatted text | <pre> preformatted </pre> |
The effect in wiki differs from the one in HTML; in wiki, the text within the PRE element is treated as within NOWIKI element, leaving all the HTML and wiki markup uninterpreted. |
| Blockquote | <blockquote>Longer passage.</blockquote> |
|
| Comments | <!-- comment --> |
Avoid nesting, such as <!-- <!-- comment --> --> |
| Generic inline element | <span style="TODO"></span> |
Can be styled arbitrarily using cascading style sheets - CSS. |
| Generic block element | <div style="TODO"></div> |
Can be styled arbitrarily using cascading style sheets - CSS. |
Some HTML elements are not allowed, such as A and IMG.
[edit] Source code
Source code of various programming and markup languages can be formatted using <source> element, which leads to colored syntax of the code.
An example of wiki markup:
<source lang="html4strict">
<html>
<body>
<p>Hello <span style="font-weight: bold;">world</span>!
</p>
</body>
</html>
</source>
The rendering of that markup:
<html> <body> <p>Hello <span style="font-weight: bold;">world</span>! </p> </body> </html>