Aspect ratio is the proportion between the width and height of an element, written as two numbers separated by a colon, such as 16:9 or 4:3. It describes the shape of a box regardless of its actual size, so a 16:9 thumbnail and a 16:9 cinema screen are the same shape at different scales.
A photograph is the easiest example. Print a portrait snapshot to fit a square frame and either the sides get cropped off or the face gets squashed. The web has the same problem: drop a wide banner into a tall slot and it distorts. Holding a fixed aspect ratio keeps images looking right and, just as usefully, lets the browser reserve the correct space before a photo loads, so the page does not jump. That makes ratio a quiet but real part of responsive design and a key detail for any product photo grid.
Common ratios each have a home: 16:9 for video, 1:1 for social tiles and avatars, 4:5 for portrait posts. Picking one and sticking to it is what makes a gallery or a card layout feel orderly.
CSS makes this easy to enforce. The aspect-ratio property lets you tell a box to stay, say, 16:9 no matter how wide the screen gets, and pairing it with object-fit: cover crops an odd image to fill the frame cleanly instead of stretching it. The choice has a content side too: a tall 4:5 image takes more vertical space and pushes other elements down, while a wide 16:9 reads as calmer. Picking a ratio is partly a layout decision and partly an editorial one.
At TopDevs we lock consistent aspect ratios into a client’s image library and templates, which keeps galleries tidy and stops the layout shifting while pictures load.