Jump to content

Template:Caption/Doc: Difference between revisions

From NixOS Wiki
DoggoBit (talk | contribs)
Created page with "Use this template to show a figure with a corresponding caption. {{caption|100px|The MediaWiki logo}} === Usage === Simply include the figure content as the first argument to the template, and the caption as the second: {{code|lang=mediawiki|line=no|<nowiki>{{caption|100px|The MediaWiki logo}}</nowiki>}} You can also optionally set an alignment. By default, it will "break" the text before and after it..."
 
DoggoBit (talk | contribs)
No edit summary
Line 1: Line 1:
Use this template to show a figure with a corresponding caption.
Use this template to show a figure with a corresponding caption. For accessibility purposes, the template also includes an <code>alt</code> that will be used by screen readers to describe what the content inside the figure is. '''Do use the alt text''', it is useful in 99% of cases.


{{caption|[[File:MediaWiki-2020-logo.svg|100px]]|The MediaWiki logo}}
{{caption|alt=The MedaWiki logo, a stylised flower with an empty interior; the petals take colours from orange to burgundy in a gradient|[[File:MediaWiki-2020-logo.svg|100px]]|The MediaWiki logo}}


=== Usage ===
=== Usage ===
Line 7: Line 7:
Simply include the figure content as the first argument to the template, and the caption as the second:
Simply include the figure content as the first argument to the template, and the caption as the second:


{{code|lang=mediawiki|line=no|<nowiki>{{caption|[[File:MediaWiki-2020-logo.svg|100px]]|The MediaWiki logo}}</nowiki>}}
{{code|lang=mediawiki|line=no|<nowiki>
{{caption
  |alt=The MedaWiki logo, a stylised flower with an empty interior; the petals take colours from orange to burgundy in a gradient
  |[[File:MediaWiki-2020-logo.svg|100px]]
  |The MediaWiki logo
}}</nowiki>}}


You can also optionally set an alignment. By default, it will "break" the text before and after it. If setting the alignment to "right" or "left", the text will flow besides the figure. If setting it to "center", the figure will be positioned in the middle, but it will still break the text flow.
You can also optionally set an alignment. By default, it will "break" the text before and after it. If setting the alignment to "right" or "left", the text will flow besides the figure. If setting it to "center", the figure will be positioned in the middle, but it will still break the text flow.


{{code|lang=mediawiki|line=no|<nowiki>{{caption|align=left|[[File:MediaWiki-2020-logo.svg|100px]]|The MediaWiki logo}}</nowiki>}}
{{code|lang=mediawiki|line=no|<nowiki>
{{caption
  |alt="The MedaWiki logo, a stylised flower with an empty interior; the petals take colours from orange to burgundy in a gradient"
  |align=left
  |[[File:MediaWiki-2020-logo.svg|100px]]
  |The MediaWiki logo
}}</nowiki>}}


{{caption|align=left|[[File:MediaWiki-2020-logo.svg|100px]]|The MediaWiki logo}}
{{caption|alt="The MedaWiki logo, a stylised flower with an empty interior; the petals take colours from orange to burgundy in a gradient"|align=left|[[File:MediaWiki-2020-logo.svg|100px]]|The MediaWiki logo}}
This text flows alongside the figure.
This text flows alongside the figure.


<div style="clear: both;"></div>
<div style="clear: both;"></div>


{{code|lang=mediawiki|line=no|<nowiki>{{caption|align=right|[[File:MediaWiki-2020-logo.svg|100px]]|The MediaWiki logo}}</nowiki>}}
{{code|lang=mediawiki|line=no|<nowiki>
{{caption
  |alt="The MedaWiki logo, a stylised flower with an empty interior; the petals take colours from orange to burgundy in a gradient"
  |align=right
  |[[File:MediaWiki-2020-logo.svg|100px]]
  |The MediaWiki logo
}}</nowiki>}}


{{caption|align=right|[[File:MediaWiki-2020-logo.svg|100px]]|The MediaWiki logo}}
{{caption|alt="The MedaWiki logo, a stylised flower with an empty interior; the petals take colours from orange to burgundy in a gradient"|align=right|[[File:MediaWiki-2020-logo.svg|100px]]|The MediaWiki logo}}
This text flows alongside the figure.
This text flows alongside the figure.


<div style="clear: both;"></div>
<div style="clear: both;"></div>


{{code|lang=mediawiki|line=no|<nowiki>{{caption|align=center|[[File:MediaWiki-2020-logo.svg|100px]]|The MediaWiki logo}}</nowiki>}}
{{code|lang=mediawiki|line=no|<nowiki>
{{caption
  |alt="The MedaWiki logo, a stylised flower with an empty interior; the petals take colours from orange to burgundy in a gradient"
  |align=center
  |[[File:MediaWiki-2020-logo.svg|100px]]
  |The MediaWiki logo
}}</nowiki>}}


{{caption|align=center|[[File:MediaWiki-2020-logo.svg|100px]]|The MediaWiki logo}}
{{caption|alt="The MedaWiki logo, a stylised flower with an empty interior; the petals take colours from orange to burgundy in a gradient"|align=center|[[File:MediaWiki-2020-logo.svg|100px]]|The MediaWiki logo}}
This text shows up below the figure.
This text shows up below the figure.
<includeonly>
=== Template data ===
<templatedata>
{
  "description": "Show a figure with a corresponding caption",
  "params": {
    "1": {
      "label": "Figure content",
      "description": "The content of the figure, that will be captioned",
      "type": "content",
      "required": true,
    },
    "2": {
      "label": "Caption",
      "description": "The caption to the figure, presenting additional information",
      "type": "line",
      "required": true,
    },
    "alt": {
      "label": "Alternative text",
      "description": "Used by screen readers to describe the content of the figure",
      "type": "line",
      "suggested": true,
    },
    "align": {
      "label": "Alignment"
      "description": "Align the figure to the left, right or centre",
      "type": "string",
      "suggested": true,
      "suggestedvalues": [
        "left",
        "right",
        "center"
      ]
    }
  }
}
</templatedata></includeonly>

Revision as of 16:16, 11 June 2025

Use this template to show a figure with a corresponding caption. For accessibility purposes, the template also includes an alt that will be used by screen readers to describe what the content inside the figure is. Do use the alt text, it is useful in 99% of cases.

The MediaWiki logo

Usage

Simply include the figure content as the first argument to the template, and the caption as the second:

{{caption
  |alt=The MedaWiki logo, a stylised flower with an empty interior; the petals take colours from orange to burgundy in a gradient
  |[[File:MediaWiki-2020-logo.svg|100px]]
  |The MediaWiki logo
}}

You can also optionally set an alignment. By default, it will "break" the text before and after it. If setting the alignment to "right" or "left", the text will flow besides the figure. If setting it to "center", the figure will be positioned in the middle, but it will still break the text flow.

{{caption
  |alt="The MedaWiki logo, a stylised flower with an empty interior; the petals take colours from orange to burgundy in a gradient"
  |align=left
  |[[File:MediaWiki-2020-logo.svg|100px]]
  |The MediaWiki logo
}}
The MediaWiki logo

This text flows alongside the figure.

{{caption
  |alt="The MedaWiki logo, a stylised flower with an empty interior; the petals take colours from orange to burgundy in a gradient"
  |align=right
  |[[File:MediaWiki-2020-logo.svg|100px]]
  |The MediaWiki logo
}}
The MediaWiki logo

This text flows alongside the figure.

{{caption
  |alt="The MedaWiki logo, a stylised flower with an empty interior; the petals take colours from orange to burgundy in a gradient"
  |align=center
  |[[File:MediaWiki-2020-logo.svg|100px]]
  |The MediaWiki logo
}}
The MediaWiki logo

This text shows up below the figure.