Template:Center/doc: Difference between revisions
Jump to navigation
Jump to search
ArrowHead294 (talk | contribs) mNo edit summary |
ArrowHead294 (talk | contribs) mNo edit summary |
||
| (3 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
{{dochead}}{{wikipedia}} | {{dochead}}{{wikipedia}} | ||
The <code><nowiki> | The <code><<nowiki />center></code> tag in {{w|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 <code><<nowiki />div></code> elements as a workaround so that they do not need to be typed in every time something needs to be centered:{{clear}} | ||
< | <syntaxhighlight lang="html"> | ||
<div style="text-align: center;"> | |||
<div style="margin: auto auto auto auto;"> | <div style="margin: auto auto auto auto;"> | ||
... | ... | ||
</div> | </div> | ||
</div></ | </div> | ||
</syntaxhighlight> | |||
{{tlx|centre | {{tlx|centre}} works as well. | ||
=== Parameters === | === Parameters === | ||
; <code><nowiki> | ; <code>{{{<nowiki />1}}}</code> (required) | ||
: One unnamed parameter, consisting of the text to be centered. | : One unnamed parameter, consisting of the text to be centered. | ||
: {{escape notice}} | : {{escape notice}} | ||
| Line 17: | Line 19: | ||
; <code>width</code> (optional) | ; <code>width</code> (optional) | ||
: Pass in the desired width (if needed). | : Pass in the desired width (if needed). | ||
==== Margins ==== | |||
Note that, in CSS, margins specified without directional keywords are specified in the order <code><nowiki>style="margin: [top] [right] [bottom] [left];"</nowiki></code>. | |||
; <code>top</code> (optional) | ; <code>top</code> (optional) | ||
| Line 25: | Line 30: | ||
; <code>both</code> (optional) | ; <code>both</code> (optional) | ||
: Pass in | : Pass in a desired size to set both upper and lower margins to the same desired value. This will override <code>top</code> and <code>bottom</code>. | ||
Latest revision as of 14:02, 6 May 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.
Parameters
{{{1}}}(required)- One unnamed parameter, consisting of the text to be centered.
- Note: Pipe characters (
|) must be escaped as{{!}}or{{pipe}}, equals signs must be escaped as{{=}}(this may apply to tags as well, e.g.<div style{{=}}"…">), and other special characters and character sequences may need to be escaped accordingly, except for ones inside<nowiki>,<pre>,<math>, and<syntaxhighlight>tags.
width(optional)- Pass in the desired width (if needed).
Margins
Note that, in CSS, margins specified without directional keywords are specified in the order style="margin: [top] [right] [bottom] [left];".
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 a desired size to set both upper and lower margins to the same desired value. This will override
topandbottom.
