Template:Flag list/doc

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search

This template is identical to Template:Flag except that the names are aligned correctly with flag icons of different widths. It is for use in lists of countries, states, provinces, etc.. See the documentation of Template:Flag for general documentation and available parameters.

Examples

[edit source]
{{flag list}} and table=yes parameter {{flag list}} {{flag}}
File:Flag of Paraguay.svg Paraguay
File:Flag of San Marino.svg San Marino
File:Flag of Palau.svg Palau
File:Flag of Australia (converted).svg Australia
File:Flag of Nepal.svg Nepal
File:Flag of Brazil.svg Brazil
File:Flag of Iran.svg Iran
File:Flag of Switzerland (Pantone).svg Switzerland
File:Flag of Qatar.svg Qatar
File:Flag of the People's Republic of China.svg China
File:Flag of Niger.svg Niger
File:Flag of Bosnia and Herzegovina.svg Bosnia-Herzegovina
File:Flag of Romania (1948–1952).svg Socialist Republic of Romania
File:Flag of the Soviet Union.svg Soviet Union
File:Flag of Hungary.svg Hungarian People's Republic
File:Flag of Ukraine.svg Ukraine


  • {{flag list|Georgia (U.S. state)|name=Georgia}}File:Flag of Georgia (U.S. state).svg Georgia
    <span class="flagicon" style="display:inline-block;width:25px;">[[File:Flag of Georgia (U.S. state).svg|23x15px|border |alt=|link=]]</span>&nbsp;[[Georgia (U.S. state)|Georgia]]
  • {{flag list|Germany}}File:Flag of Germany.svg Germany
    <span class="flagicon" style="display:inline-block;width:25px;">[[File:Flag of Germany.svg|23x15px|border |alt=|link=]]</span>&nbsp;[[Germany|Germany]]
  • {{flag list|Germany|empire}}File:Flag of the German Empire.svg Germany
    <span class="flagicon" style="display:inline-block;width:25px;">[[File:Flag of the German Empire.svg|23x15px|border |alt=|link=]]</span>&nbsp;[[Germany|Germany]]
  • {{flag list|Romania}}File:Flag of Romania.svg Romania
    <span class="flagicon" style="display:inline-block;width:25px;">[[File:Flag of Romania.svg|23x15px|border |alt=|link=]]</span>&nbsp;[[Romania|Romania]]
  • {{flag list|Romania|1948}}File:Flag of Romania (1948-1952).svg Romania
    <span class="flagicon" style="display:inline-block;width:25px;">[[File:Flag of Romania (1948-1952).svg|23x15px|border |alt=|link=]]</span>&nbsp;[[Romania|Romania]]
  • {{flag list|Socialist Republic of Romania|short=yes}}File:Flag of Romania (1965–1989).svg Romania
    <span class="flagicon" style="display:inline-block;width:25px;">[[File:Flag of Romania (1965–1989).svg|23x15px|border |alt=|link=]]</span>&nbsp;[[Socialist Republic of Romania|Romania]]
  • {{flag list|UN}}File:Flag of the United Nations.svg UN
    <span class="flagicon" style="display:inline-block;width:25px;">[[File:Flag of the United Nations.svg|23x15px|border |alt=|link=]]</span>&nbsp;[[United Nations|UN]]
  • {{flag list|World}}File:Flag placeholder.svg World
    <span class="flagicon" style="display:inline-block;width:25px;">[[File:Flag placeholder.svg|23x15px| |alt=|link=]]</span>&nbsp;[[World|World]]
  • {{flag list|ITA}}File:Flag of Italy.svg ITA
    <span class="flagicon" style="display:inline-block;width:25px;">[[File:Flag of Italy.svg|23x15px|border |alt=|link=]]</span>&nbsp;[[Italy|ITA]]
  • {{flag list|SUI}}File:Flag of Switzerland (Pantone).svg SUI
    <span class="flagicon" style="display:inline-block;width:25px;">[[File:Flag of Switzerland (Pantone).svg|23x16px|border |alt=|link=]]</span>&nbsp;[[Switzerland|SUI]]
  • {{flag list|Switzerland}}File:Flag of Switzerland (Pantone).svg Switzerland
    <span class="flagicon" style="display:inline-block;width:25px;">[[File:Flag of Switzerland (Pantone).svg|23x16px|border |alt=|link=]]</span>&nbsp;[[Switzerland|Switzerland]]
  • {{flag list|Union of Soviet Socialist Republics|table=yes}}
File:Flag of the Soviet Union.svg Union of Soviet Socialist Republics
{| style="margin-left:-3px"
|-
| <span class="flagicon" style="display:inline-block;width:25px;">[[File:Flag of the Soviet Union.svg|23x15px|border |alt=|link=]]</span> 
| style="padding-left:2px;" | [[Soviet Union|Union of Soviet Socialist Republics]]

|}
  • {{flag list|ITA|size=46x30px}}File:Flag of Italy.svg ITA
    <span class="flagicon" style="display:inline-block;width:48px;">[[File:Flag of Italy.svg|46x30px|border |alt=|link=]]</span>&nbsp;[[Italy|ITA]]
  • {{flag list|SUI|size=46x30px}}File:Flag of Switzerland (Pantone).svg SUI
    <span class="flagicon" style="display:inline-block;width:48px;">[[File:Flag of Switzerland (Pantone).svg|46x30px|border |alt=|link=]]</span>&nbsp;[[Switzerland|SUI]]

How it works

[edit source]

{{Flag}} generates a flag icon, a non-breaking space and the country link, which means the alignment of the link depends on the width of the flag image. The default size for flag icons is 23x15px, so the icon width is 23px for long flags but smaller for more squarish flags such as those of San Marino and Niger (any flag with an aspect ratio less than 23/15 ≈ 1.53), misaligning the country links next to them. The {{Flag/core}} template, used internally by {{flag}}, compensates for this for Nepal, Vatican City and Switzerland by inserting some extra spaces, though for several other countries the link is still shifted too far to the left, as seen above.

{{flag list}} puts a flag icon inside an invisible <span> box with a fixed width calculated by Module:flag list. The width does not depend on the exact dimensions of the image, but does vary with the maximum width and height specified using extended image syntax. The default size for most countries' flags is 23x15px; the |size= parameter can be used if a different size is wanted. Some entities have different defaults specified within their data templates and may output misaligned links even if |size= is not used.

If a maximum width is specified (whether both width and height, e.g. 20x10px, or width only, e.g. 20px), either using the |size= parameter or the data template default, the box size is equal to this width plus seven pixels. If a height is specified but a width is not (x10px), a box width of 2.2 times the height plus seven pixels is used. In the latter case, flags with an aspect ratio greater than 2.2 (the only such current national flag being that of Qatar) may extend beyond the invisible box and overlap the country link at certain sizes, as seen in the table below. For this reason, if an icon size different from the default is wanted, it is best to always specify both a width and a height. This also ensures that neither squarish nor long flags are rendered much bigger than other flags.

Template parameters

ParameterDescriptionTypeStatus
Country1

Display the small flag icon of this country. A flag will only be displayed if the related template {{country data ⟨1⟩}} exists with the ⟨flag alias⟩ parameter (otherwise a transparent placeholder is used to preserve text alignment inside lists).

Example
Germany
Stringrequired
Custom namename

Custom name to be displayed instead of ⟨1⟩.

Stringoptional
Short nameshort

Display the ⟨shortname alias⟩ that is configured in the country data template, instead of the name given with ⟨1⟩ or ⟨name⟩. If there is no shortname alias, then ⟨alias⟩ from the country data template is used.

Default
no
Example
yes
Booleansuggested
Flag variant2 variant

Name of a variant that is configured in the country data template to display a flag variation, such as a historical flag.

Example
empire
Stringoptional
Custom flag sizesize

Custom size of the flag icon.

Default
23x15px
Example
x25px
Stringoptional
Table alignmenttable

Align country names that wrap across multiple lines next to the flag icon (by creating a table). Currently only for use within tables.

Default
no
Example
yes
Booleanoptional

Usage with custom size

[edit source]
|size= value {{flag}} output {{flag list}} output {{flag list}} with table=yes output
10px
File:Flag of Qatar.svg Qatar
File:Flag of Palau.svg Palau
File:Flag of Switzerland (Pantone).svg Switzerland
File:Flag of the Soviet Union.svg Union of Soviet Socialist Republics
x8px
File:Flag of Qatar.svg Qatar
File:Flag of Palau.svg Palau
File:Flag of Switzerland (Pantone).svg Switzerland
File:Flag of the Soviet Union.svg Union of Soviet Socialist Republics
10x8px
File:Flag of Qatar.svg Qatar
File:Flag of Palau.svg Palau
File:Flag of Switzerland (Pantone).svg Switzerland
File:Flag of the Soviet Union.svg Union of Soviet Socialist Republics
35px
File:Flag of Qatar.svg Qatar
File:Flag of Palau.svg Palau
File:Flag of Switzerland (Pantone).svg Switzerland
File:Flag of the Soviet Union.svg Union of Soviet Socialist Republics
x25px
File:Flag of Qatar.svg Qatar
File:Flag of Palau.svg Palau
File:Flag of Switzerland (Pantone).svg Switzerland
File:Flag of the Soviet Union.svg Union of Soviet Socialist Republics
35x25px
File:Flag of Qatar.svg Qatar
File:Flag of Palau.svg Palau
File:Flag of Switzerland (Pantone).svg Switzerland
File:Flag of the Soviet Union.svg Union of Soviet Socialist Republics


Alternatives to avoid Wikipedia's Post-expand include size limit

[edit source]

Pages with many flag icons may come close to or exceed Wikipedia's Post-expand include size limit. In these cases consider using modules or module-wrapper templates instead:

  • {{flagg}} is a simple wrapper for Module:Flagg: For basic use, {{flag list|country}} can be replaced with {{flagg|usc|country}}
  • {{#invoke:flag|list}} is a wrapper for Module:Flagg that can further reduce sizes when invoked directly. For basic use, {{flag list|country}} can be replaced with {{#invoke:flag|list|country}}.