Why this wireframe works | Masonry gallery
Photos shown without cropping
Photos keep their original ratios, so portrait and landscape shots alike show their full composition.
No gaps despite differing ratios
Photos are packed into each column from the top, so photos of differing ratios leave no large gaps between them.
A title under each photo
Whatever the ratio, the title and description sit under the photo in the same form. Photos of different sizes are read the same way.
Two columns on mobile
Three columns make the photos too small on mobile, so they sit in two. Because a run of portrait photos gets long, fewer items are shown.
Common mistakes | Masonry gallery
Reading and keyboard order that differs from the visual order
When packed by column, the visual order and the HTML order may not match. Avoid it for lists where order matters, or build it so the visual order follows the HTML.
Layout shifting as photos load
Laying photos out before their sizes are known makes the layout move while loading. Specify each photo’s aspect ratio in advance.
One extremely tall photo stretching the list
A single very tall photo lengthens its whole column. Set a maximum ratio for the list and crop photos that exceed it.
Three columns on mobile
Three columns on mobile make the photos too small to show their composition. Use two columns or one on mobile.
Visual order that differs from reading order
With cards of different heights, the visual order can drift from the HTML and Tab order. Keep the visual order, HTML order and Tab order the same, and do not reorder things visually with CSS. Check with a screen reader and the keyboard.
FAQ | Masonry gallery
Can masonry be built with CSS alone?
CSS multi-column layout (columns) gives a close result. Note that items then flow top to bottom within each column, which differs from reading across.
How should the photo order be decided?
Because items are packed by column, fine ordering does not come across. Put the photos you most want seen first, and avoid it for lists ordered by date or similar.
Should pressing a photo enlarge it?
When the point is showing composition, enlarging lets readers see the detail. See the lightbox.











