In Wiki markup, particularly in MediaWiki (used by Wikipedia and similar platforms), you can write monospaced text over multiple lines (e.g., a code block) using the following methods:
✅ Recommended Methods
1. Using <pre> Tags
This is the standard and most reliable way to create a monospaced block that preserves whitespace and line breaks:
wiki
<pre>
This is a block of monospaced text.
You can write multiple lines here.
</pre>
This will render as:
code
This is a block of monospaced text.
You can write multiple lines here.
Preserves formatting: Whitespace, line breaks, and indentation.
Monospaced font: Typically rendered in a fixed-width font.
Disables wiki markup: Any wiki syntax inside <pre> is treated as plain text.
2. Using <syntaxhighlight> Tags (If Available)
If the wiki has the SyntaxHighlight extension (common in technical documentation wikis), you can use:
Syntax highlighting for specific languages (like Python, JavaScript, etc.)
⚠️ Alternative (Less Reliable)
3. Line-by-Line Indentation with a Space
You can also start each line with a space to create preformatted text:
wiki
This is a line of monospaced text.
This is another line.
This will render as:
code
This is a line of monospaced text.
This is another line.
Note: This method is less reliable for long blocks and may cause issues with transclusion or template parsing.
❌ Not Suitable for Blocks
<code> Tags: These are for inline code only and do not support multiline blocks.
Triple Backticks (`): Common in Markdown, but not supported in standard MediaWiki.
Summary
Method
Multiline Support
Monospaced
Syntax Highlight
Notes
<pre>
✅ Yes
✅ Yes
❌ No
Most reliable
<syntaxhighlight>
✅ Yes
✅ Yes
✅ Yes
Requires extension
Leading space
✅ Yes
✅ Yes
❌ No
Less reliable
Final Recommendation
For general use in Wiki markup, use <pre> tags to ensure your block of monospaced text renders correctly across all platforms. If syntax highlighting is needed, use <syntaxhighlight> if the extension is available.