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.

How to use CSS Aspect-Ratio Generator

CSS Aspect-Ratio Generator helps you work with width-to-height proportions rather than guessing at image shape. An aspect ratio is written as width:height. It describes the shape of the canvas, not the number of pixels or the file size.

For example, 1920 × 1080 reduces to 16:9 because both values can be divided by 120. A 1280 × 720 image has the same 16:9 shape even though it contains fewer pixels. A square 1080 × 1080 image is 1:1, while 1080 × 1350 is 4:5.

How to get a dependable result: enter positive whole-number pixel values when working with raster images, check that the width and height are in the correct fields, and review the displayed result before using it. If you are working from a screenshot or an image supplied by someone else, confirm that it has not already been cropped or stretched.

Aspect ratio, resolution and file size answer different questions. Aspect ratio describes shape; resolution describes the number of pixels; file size describes how much storage or transfer data the file uses. You may need to manage all three for a website, application form, social post or print project. Reducing pixel dimensions can lower file size, but it is not the only compression method.

Common mistakes include swapping width and height, assuming that every platform uses the same image dimensions, and changing only one dimension when the goal is proportional resizing. For a landscape image, width is normally greater than height; for a portrait image, height is greater. A square uses equal dimensions. Always confirm the orientation expected by the destination.

For mobile-friendly design, test the result at a narrow viewport as well as on a desktop screen. Keep important text and subjects away from the edges, because responsive layouts and platform previews may crop content differently. Use descriptive filenames and an appropriate modern image format when supported, while retaining a compatible fallback if a service requires one.

This tool is a calculation aid, not a guarantee that a third-party website will accept a file. Upload limits, supported formats, maximum dimensions and image-quality rules can change. Check the destination's own instructions before submitting important documents or publishing campaign artwork. When accuracy matters, compare the exported file's actual properties with the required values.