Template:Center/doc: Difference between revisions

From Xenharmonic Wiki
Jump to navigation Jump to search
ArrowHead294 (talk | contribs)
m Styling doesn't need to be done here
ArrowHead294 (talk | contribs)
mNo edit summary
Line 1: Line 1:
{{dochead}}
{{dochead}}
The <code><nowiki><center></nowiki></code> tag was deprecated in HTML&nbsp;4, and there is no easy replacement for it. This template replicates the tag's functionality using a workaround via nested <code><nowiki><div></nowiki></code> elements:
The <code><nowiki><center></nowiki></code> tag in {{w|HTML}} is now deprecated, and there is no easy replacement for it. This template is designed to replicate the tag's functionality using nested <code><nowiki><div></nowiki></code> elements as a workaround:


<pre><div style="text-align: center;">
<pre><div style="text-align: center;">
Line 8: Line 8:
</div></pre>
</div></pre>


This template eliminates the need to manually type out the <code><nowiki><div></nowiki></code> elements every time something needs to be centered.
This way, there is no need to manually type out the needed elements every time something needs to be centered.


=== Parameters ===
=== Parameters ===
Line 15: Line 15:


; <code>top</code> '''(optional)'''
; <code>top</code> '''(optional)'''
: Pass in the desired upper margin. The default value is <code>auto</code>.
: Pass in the desired upper margin; the default value is <code>auto</code>.


; <code>bottom</code> '''(optional)'''
; <code>bottom</code> '''(optional)'''
: Pass in the desired lower margin. The default value is <code>auto</code>.
: Pass in the desired lower margin; the default value is <code>auto</code>.

Revision as of 19:46, 9 December 2024

The <center> tag in HTML is now deprecated, and there is no easy replacement for it. This template is designed to replicate the tag's functionality using nested <div> elements as a workaround:

<div style="text-align: center;">
    <div style="margin: auto auto auto auto;">
    ...
    </div>
</div>

This way, there is no need to manually type out the needed elements every time something needs to be centered.

Parameters

{{{1}}} (required)
One unnamed parameter, consisting of the text to be centered.
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.