Template:Center/doc: Difference between revisions

From escforumwiki
Jump to navigation Jump to search
en>Jdaloner
Modified <includeonly> section so that "sandbox" subpage won't appear in categories.
Santos (talk | contribs)
m 77 revisions imported
 
(42 intermediate revisions by 30 users not shown)
Line 1: Line 1:
{{Documentation subpage}}
{{Documentation subpage}}
<!--PLEASE ADD CATEGORIES AT THE END OF THIS PAGE.--->
<!-- Add categories where indicated at the bottom of this page and interwikis at Wikidata -->
A simple template to center-align content in tables and other places.
{{used in system|in [[MediaWiki:Abusefilter-top100]]}}


== Example ==
== Description ==
It is to center elements on a page. See also [[Template:Align]] for more options and flexibility.
 
== Usage ==
{{See also|Span and div}}
{{markup
{{markup
| <nowiki>{{Center|Hello world!}}</nowiki>
| <nowiki>{{Center|Hello world!}}</nowiki>
Line 10: Line 14:


To do this without a template, simply use the following code:
To do this without a template, simply use the following code:
:<code><nowiki><div class="center" style="width:auto; margin-left:auto; margin-right:auto;"></nowiki></tt>''your text''<tt><nowiki></div></nowiki></code>
<syntaxhighlight lang="HTML">
<div class="center" style="width:auto; margin-left:auto; margin-right:auto;">...</div>
</syntaxhighlight>
To center a table, see [[Help:TABLECENTER]].


To center a table, see [[Help:TABLECENTER]].
Notes:
* If the markup to be centered includes an equals sign, the markup must be preceded by <code>1=</code>. Example: <code><nowiki>{{Center|1=the <span style="color:red">red</span> one}}</nowiki></code>.
* If the markup to be centered includes a displaying pipe, the pipe must be escaped as <code><nowiki>{{!}}</nowiki></code> or <code>&amp;#124;</code>.


===Table===
=== Tables ===
Using {{tlc|left}} / {{tlc|center}} / {{tlc|right}}
{| class="wikitable"
!colspan="3" style="width:300px"| Header text
|-
| {{Left|Left}} || {{Center|Center}} || {{Right|Right}}
|}
Using {{tlc|align|left}} / {{tlc|align|center}} / {{tlc|align|right}}
{| class="wikitable"
{| class="wikitable"
!colspan="3"| Header text
!colspan="3" style="width:300px"| Header text
|-
|-
| {{Left2|Left2}} || {{Center|Center}} || {{Right|Right}}
| {{align|left|Left}} || {{align|center|Center}} || {{align|right|Right}}
|}
|}
== Tracking category ==
Pages, which use {{tl|Center}} without an argument, are added to the {{clc|Pages using center with no arguments}}.
== TemplateData ==
{{TemplateDataHeader}}
<templatedata>
{
"params": {
"1": {
"label": "Content",
"type": "content",
"required": true,
"description": "Content to be centered"
},
"style": {
"label": "Custom CSS"
}
},
"description": "A simple template to center-align content in tables and other places. Be aware that the center class is applied to this template, which means every element within the template has its left and right margins set to auto. This may harm some templates."
}
</templatedata>


== See also ==
== See also ==
*{{hlist |{{tl|Startcenter}} |{{tl|Endcenter}}}}
* {{tl|Center block}}
*{{tl|Left}}
* {{tl|align}}
*{{tl|Left2}}
* {{tl|right}}, {{tl|left}} and {{tl|justify}}
*{{tl|Right}}
* {{tl|Image frame}}


<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox||
<includeonly>{{sandbox other||
<!---CATEGORIES AFTER THIS LINE, PLEASE--->
<!-- Categories below this line; interwikis at Wikidata -->
[[Category:Positioning templates]]
[[Category:Typing-aid templates]]
[[Category:Typing-aid templates]]
[[Category:Wikipedia formatting and function templates]]
[[Category:Wikipedia XHTML tag-replacing templates]]
[[Category:Wikipedia XHTML tag-replacing templates]]
}}</includeonly>
}}</includeonly>

Latest revision as of 18:21, 12 June 2022

Description

It is to center elements on a page. See also Template:Align for more options and flexibility.

Usage

Markup Renders as
{{Center|Hello world!}}
Hello world!

To do this without a template, simply use the following code:

<div class="center" style="width:auto; margin-left:auto; margin-right:auto;">...</div>

To center a table, see Help:TABLECENTER.

Notes:

  • If the markup to be centered includes an equals sign, the markup must be preceded by 1=. Example: {{Center|1=the <span style="color:red">red</span> one}}.
  • If the markup to be centered includes a displaying pipe, the pipe must be escaped as {{!}} or &#124;.

Tables

Using {{left}} / {{center}} / {{right}}

Header text
Left
Center
Right

Using {{align|left}} / {{align|center}} / {{align|right}}

Header text
Left
Center
Right

Tracking category

Pages, which use {{Center}} without an argument, are added to the Category:Pages using center with no arguments (0).

TemplateData

This is the TemplateData for this template used by TemplateWizard, VisualEditor and other tools. See a monthly parameter usage report for Template:Center in articles based on its TemplateData.

TemplateData for Center

A simple template to center-align content in tables and other places. Be aware that the center class is applied to this template, which means every element within the template has its left and right margins set to auto. This may harm some templates.

Template parameters

ParameterDescriptionTypeStatus
Content1

Content to be centered

Contentrequired
Custom CSSstyle

no description

Unknownoptional

See also