Why Every Tile in a Gallery Needs an Identifier of Its Own
You tap a photograph in a gallery and it opens full size, with the rest of the set behind it. Simple to use, and it depends on something that has to be right for it to work at all: every tile on the page needs its own unique name.
How opening a photo actually works
Each thumbnail carries an identifier, and the lightbox that opens is told which identifier to show. Tap the fourth photograph and the viewer is asked for the fourth identifier.
An identifier is meant to name exactly one element on a page. When two elements share one, nothing reports an error. Every mechanism that looks one up silently takes the first match it finds: a script, a stylesheet rule, a link pointing at it, the browser's own accessibility layer.
The consequence in a gallery is specific and confusing. Tap the fourth photograph, and the viewer opens the first one, because the first one answered to that name too. Nothing is broken in a way you could report. It just shows you the wrong picture.
Why it is easy to get wrong
Duplicate identifiers are a classic result of a page assembled from repeated pieces. A block of markup written once, correct in isolation, is rendered twelve times in a loop, and the identifier written into it is rendered twelve times with it.
The same thing happens when a page includes the same component twice: a gallery in the main content and a smaller one in a sidebar, each perfectly valid on its own.
So identifiers on repeated elements are derived from the thing they name rather than written into the template, which is what makes them unique by construction rather than by anybody remembering.
What this means for you
Nothing to configure. It is worth knowing about mainly because it explains a symptom that is otherwise baffling: a gallery where tapping one image opens another. If you ever see that on any site, this is almost always why.
Related: alt text on every image, which is the other half of making a gallery work for everybody, and how every design is checked, which is where this class of thing gets found.
Browse the catalog or create a free actor website.
