Jump to content

Template:Resize/doc

From Wikibooks, open books for an open world

The {{Resize}} template is used to change the font size of the text supplied to it. It is primarily intended for text strings within a single paragraph or list item, but can also be configured for use with entire lists or text which spans multiple paragraphs.

{{Resize|N|text}} N specifies a valid CSS length unit. This can be relative, such as 2vw (2% of the page width) or 1.2rem (120% of the browser's default text size), or absolute, as in 14px (14 device pixels) or 2pc (2 pica, or 24 device pixels).
{{Resize|text}} Here, where no size is specified, a fallback value of 1.67vw is applied, unless that exceeds a minimum of 0.9rem or maximum of 0.98rem, in which case those values are used instead.
{{Resize|text|div=yes}} The text is resized as described in the previous example, but wrapped in block element tags rather than inline, permitting the use of paragraphs separated by empty lines.

Limitations

[edit source]

Beware that if text happens to contain an equality sign or signs (=), it will fail to render properly. Here are the workarounds:

  1. Use the named parameter |text= instead of supplying the content as an unnamed parameter, as in {{Resize|text=text}}.
  2. Replace all instances of = with {{=}}.
  3. Specify your text using positional parameters, as in {{Resize|N|2=text}} or {{Resize|1=text}}.

Also it will fail to wrap multiple blocks, such as multiple paragraphs or multiple bullet points. Here are the workarounds:

  1. Use {{Resize|…|div=yes}}, or
  2. Apply this template separately to each paragraph or list item using only the first one or two parameters, or
  3. Indulge in some wiki-nostalgia and wrap it all in div tags by hand, as in
    <div style="font-size:90%;">
    ...multiple paragraphs...
    </div>.

Examples

[edit source]
Wikicode Result
{{Resize|This text uses the fallback character size reduction appropriate to the device viewing it.}}
This text uses the fallback character size reduction appropriate to the device viewing it.
(1 2/3% of the page width or the bounding values of 90%/98% of the browser's default text size)
{{Resize|0.8rem|This text is 80% of the browser's default text size.}} This text is 80% of the browser's default text size.
{{Resize|1.2rem|This text is 20% larger than the browser's default text size.}} This text is 20% larger than the browser's default text size.
{{Resize|We know 1+1=2 and 2+2=4 will fail to render because of the equality signs.}} {{{1}}}
{{Resize|We know 1+1{{=}}2 and 2+2{{=}}4.}} We know 1+1=2 and 2+2=4.
{{Resize|text=We know 1+1=2 and 2+2=4.}} We know 1+1=2 and 2+2=4.
{{Resize|size=1.25rem|2=We know 1+1=2 and 2+2=4. This text is 25% larger than the browser's default text size.}} We know 1+1=2 and 2+2=4. This text is 25% larger than the browser's default text size.

TemplateData

[edit source]
This is the TemplateData for this template used by TemplateWizard, VisualEditor and other tools. Click here to see a monthly parameter usage report for this template based on this TemplateData.

TemplateData for Resize

Uses inline CSS font-size property within <div> or <span> tags to alter the size of the text supplied to it

Template parameters

This template prefers inline formatting of parameters.

ParameterDescriptionTypeStatus
Font sizesize

A valid CSS length value, absolute or relative

Default
clamp(0.9rem, 1.67vw, 0.98rem)
Example
1.1rem
Linesuggested
texttext

no description

Unknownoptional
divdiv

no description

Unknownoptional
11

no description

Unknownoptional
22

no description

Unknownoptional

See also

[edit source]