Template:Center/doc: Difference between revisions
mNo edit summary |
mNo edit summary |
||
| (One intermediate revision by the same user not shown) | |||
| Line 12: | Line 12: | ||
; <code><nowiki>{{{1}}}</nowiki></code> (required) | ; <code><nowiki>{{{1}}}</nowiki></code> (required) | ||
: One unnamed parameter, consisting of the text to be centered. | : One unnamed parameter, consisting of the text to be centered. | ||
: {{escape notice}} | |||
; <code>width</code> (optional) | ; <code>width</code> (optional) | ||
Latest revision as of 17:03, 27 January 2025
The <center> tag in HTML is now deprecated, and there is no one-size-fits-all replacement for it. This template is designed to replicate the tag's functionality using nested <div> elements as a workaround so that they do not need to be typed in every time something needs to be centered:
<div style="text-align: center;">
<div style="margin: auto auto auto auto;">
...
</div>
</div>
{{centre}} works as well.
ParametersEdit
{{{1}}}(required)- One unnamed parameter, consisting of the text to be centered.
- Note: Pipe characters (
|) must be escaped as{{!}}or{{pipe}}, and equals signs must be escaped as{{=}}(those inside tags may need to be escaped as well, e.g.<div style{{=}}"...">), except for ones inside<nowiki>,<pre>,<math>, and<syntaxhighlight>tags.
width(optional)- Pass in the desired width (if needed).
top(optional)- Pass in the desired upper margin; the default value is
auto.
bottom(optional)- Pass in the desired lower margin; the default value is
auto.
both(optional)- Pass in this to set both upper and lower margins to the same desired value. Note that this will override any margin specified using
toporbottom.