Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Template:Example: Difference between revisions

Template page
m Remove extra line break
Change background color.
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Color box|color=#404050|border=#9999AA|{{{1|An example!}}} }}<noinclude>
{{Color box
== Documentation ==
|border= #6666a8
As the name suggests, this template produces a colored box, which is used when you want to give an example on a page. You can use common wiki-formatting (eg bold, links) if you wish.
|width= {{{width|95%}}}
 
|color= #0080FF
If the text you would like to use include an equals sign (=), you need to explicitly declare your text as a numbered parameter (i.e. put <code>1=</code> before your example text), otherwise the template will display nothing.
|align= left
 
|text= white
=== Examples ===
|italics= no
 
|{{{1|An example!}}}
<code><nowiki>{{example|An example to '''illustrate''' my article with a link to the [[Venture]].}}</nowiki></code> gives:
}}<noinclude>
{{example|An example to '''illustrate''' my article with a link to the [[Venture]].}}
{{documentation}}
 
</noinclude>
<code><nowiki>{{example|How not to put the formula 2+2=4 into an example.}}</nowiki></code> gives:
{{example|How not to put the formula 2+2=4 into an example.}}
 
<code><nowiki>{{example|1=How to put the formula 2+2=4 into an example.}}</nowiki></code> gives:
{{example|1=How to put the formula 2+2=4 into an example.}}
 
[[Category:Template]]</noinclude>

Latest revision as of 11:18, 28 May 2025

An example!
Template documentation (for the above template, sometimes hidden or invisible)
Description
Produces a centered, colored box, which is used to present an example on a page.
Dependencies
Uses
{{Color box}}
Syntax
{{Example|<content>|<width= width>}}
Parameters
content
The example text inside the box. The box has "An example!" as the default text. If the text includes an equals sign (=), the text needs to be explicitly declared as a numbered parameter (i.e. put 1= before the text), otherwise the template will display the default text.
width
Sets the width of the box. It's recommended to set this as a percentage (of the paragraph width), so 50% will produce a text box half as wide as the surrounding paragraph. The default width is set at 95%. When width is set to less than 100%, the box will be centered.
Examples
{{Example|An example to ''illustrate'' my article with a link to the [[Venture]].}}
gives ...
An example to illustrate my article with a link to the Venture.


{{Example|How not to put the formula 2+2=4 into an example.}}
gives ...
An example!


{{Example|1= How to put the formula 2+2=4 into an example.}}
gives ...
How to put the formula 2+2=4 into an example.


See also
Template data
This is the TemplateData documentation for this template used by VisualEditor and other tools.

Box to present examples in articles. When the (optional) width is set to less then 100% the box will be centered.

Template parameters[Edit template data]

This template has custom formatting.

ParameterDescriptionTypeStatus
Content1

The content of the example box. If the text includes an equals sign (=), the text needs to be explicitly declared as a numbered parameter (i.e. put 1= before the text), otherwise the template will display the default text.

Default
An example!
Contentrequired
widthwidth

Set the width of the box. Preferably in %

Default
95%
Stringoptional
Visit Template:Example/doc to edit this text! (How does this work?) (Refresh this text - why?)