Help:Gallery tag

A gallery displays several pictures in an array or similar layout.

Galleries can display images formed into rows and columns by use of the  parser (conversion of Wikitext to HTML) tag. Be aware that different screen size and browsers may affect accessibility for some readers.

Attributes and values
Attributes and values go after the word  and a blank space, and before the ending angle bracket:
 * Default, effect is explained below
 * No borders, less padding, captions centered under images
 * All images aligned by having same height, justified, captions centered under images
 * Like packed, but caption overlays the image, in a translucent box
 * Like packed-overlay, but caption is only visible on hover (degrades gracefully on screen readers, and falls back to packed-overlay if a touch screen is used)
 * Slideshow
 * Adds an overall caption above the gallery
 * Image widths in pixels (has no effect if mode is set to packed, packed-overlay, packed-hover, or slideshow)
 * Image heights in pixels (has no effect if mode is set to slideshow)
 * Number of images per row (has no effect if mode is set to packed, packed-overlay, packed-hover, or slideshow; See usage notes, below)
 * Show each filename below the corresponding image
 * One or more class names separated with spaces and enclosed in double quotes
 * One or more CSS declarations separated with semicolons and enclosed in double quotes
 * One or more CSS declarations separated with semicolons and enclosed in double quotes

Usage notes

 * Indiscriminate use of the  attribute is strongly discouraged, because it overrides flexible use of different display sizes and aspect ratios, ranging from mobile miniature to wide "cinema" screens. However, the attribute should be used when a fixed grid arrangement is appropriate, such as "before/after", "low/medium/high", or other systematic comparisons of images.
 * If  is omitted, the width is fluid: one row comprises as many images as will fit across the available width of the user's display, wrapping automatically to as many additional lines as needed.
 * Omitting  is now the recommended default. Prior to MediaWiki 1.17, the default was 4.
 * The default width and height are currently 120px. Images displayed by the  tag do not obey user viewing preferences.
 * The  mode will automatically adjust image sizes to use available display space optimally.
 * Every line specifies an image file. The  prefix is unnecessary.
 * The parameter "thumb" is invalid and must not be used.
 * Captions are optional and are separated from file name by a vertical bar ("|").
 * Brackets ("[" or "]") must not be included, except for Wikilinks embedded within captions.
 * A common mistake is to forget the closing tag.
 * When using, note that many parameters, specifically those relating to visual appearance, may not apply or work as expected to certain skins (notably the Minerva skin used by the mobile site).

Syntax
There are several "modes" of galleries.



"Traditional" mode is currently the default, and, as such, need not be specified. The basic syntax is:

Which gives:

Extended syntax
Besides mode, the extended syntax is (see gallery tag help and hereafter for full list of parameters):

Which produces:

Other advice for using packed mode is to keep captions for particularly narrow images as short as is convenient.

Captions
For all modes except traditional, captions are centered. To left-align the captions, specify the CSS declaration  in the   attribute:

gives:

To center a caption when other options are ineffective, perhaps the most-reliable alternative is to use:

Center
To center a gallery use :

The use of the  attribute will cause this to not work. Where a specific number of images per row is desired, use separate elements. Centered galleries are the default for most variant gallery modes.