Aspect Ratio Ended the Padding Hack
aspect-ratio does in one line what used to take a wrapper and a percentage.
Where we use it
Our rule of thumb: if we cannot explain a choice in one sentence to a client, we probably should not ship it.
- Card thumbnails
- Embedded video frames
- Gallery tiles
Borders do a lot of quiet work. They separate content, show what can be clicked and give the eye somewhere to rest.
We deleted forty lines of wrapper CSS in one afternoon.
Performance was not the goal, but it came along anyway. Fewer styles, fewer scripts and fewer images add up quickly.
The first version looked plain. The second version looked busy. The third version, with half the details removed, is the one we kept.
We asked a few readers to try it with a keyboard only. Two of them found problems in under a minute, which is exactly why we asked.
Browser support is no longer the excuse it used to be. Everything in this post works in every current browser without a fallback.
If you only change one thing after reading this, make it the spacing. Consistent gaps make even a rough layout look intentional.
Colour is the last thing we add. Getting the structure right in black and white first saves a lot of arguing later.
None of this is new. It is the same advice print designers have given for a century, moved onto screens.
6 thoughts on “Aspect Ratio Ended the Padding Hack”
We had the same fight in our team. Sending this to everyone.
We tried that and it worked fine for us.
Simple and it works. My favourite kind of advice.
It holds up, as long as the gap stays consistent.
Our designers pushed back at first, but the results convinced them.
This changed how I think about borders.