Home / CSS Aspect-Ratio Generator

CSS Aspect-Ratio Generator

Choose a common shape or enter your own width and height. Preview the shape and copy responsive CSS using the modern aspect-ratio property—no fixed pixel height required.

Build your ratio

The values are ratio parts, not pixel dimensions. For example, 1920 × 1080 simplifies to 16:9.

Live preview

16:9

Ratio value: 1.7778

How to use the generated CSS

  1. Choose a preset or enter a custom width-to-height ratio.
  2. Copy the CSS and paste it into your stylesheet.
  3. Apply the selected class to a container or media wrapper.
  4. If using an image, choose object-fit: cover to fill the frame or contain to show the entire image.

The aspect-ratio property sets a preferred width-to-height ratio. The final rendered size still depends on the element’s layout, available width and other CSS rules.

Popular CSS aspect ratios

RatioCommon useCSS value
16:9Video players, widescreen embedsaspect-ratio: 16 / 9;
9:16Vertical video, mobile canvasaspect-ratio: 9 / 16;
1:1Square thumbnails, avatarsaspect-ratio: 1 / 1;
4:5Portrait social postsaspect-ratio: 4 / 5;
4:3Classic video, presentation framesaspect-ratio: 4 / 3;
3:2Photographsaspect-ratio: 3 / 2;

Need dimensions as pixels too? Try the aspect ratio calculator, or browse the social media image size guide.