CSS Aspect Ratio Calculator — aspect-ratio & Padding
CSS Aspect Ratio Calculator Free — CSS aspect-ratio calculator. Work out the numbers, then use aspect-ratio in CSS.
Short answer: In CSS, aspect-ratio: 16 / 9 keeps an element at 16:9 whatever its width. The older padding-top trick uses height divided by width times 100 — 56.25 percent for 16:9 and 75 percent for 4:3. Enter your ratio in the tool below to get both values.
Use the tool
Enter a width and a height. The tool gives the simplified ratio and its decimal value, which is what CSS and design tools use.
How the aspect ratio in CSS works
The aspect ratio in CSS answers one question: what happens to the shape when the numbers change? For responsive web layouts, the shape matters as much as the size. A picture that is 1920 by 1080 pixels has the ratio 16:9, which is 1.778 as a decimal. That decimal is the width divided by the height, and it tells you at a glance whether the picture is wide, square, or tall. If you keep that decimal the same while you change the size, the picture keeps its shape. If you change it, the picture stretches, and people, faces and text look wrong. This tool does the arithmetic for you, so you do not have to work out the greatest common divisor by hand, and you can check a size in seconds before you export, upload or print it.
Start with the numbers you already have. For responsive web layouts, those numbers are usually the width and height in pixels, and they are shown in your editor, your camera settings, or the file details on your computer. Enter the width first and the height second, and the tool divides both numbers by their greatest common divisor. For 1920 and 1080, that divisor is 120, so 1920 divided by 120 is 16 and 1080 divided by 120 is 9, giving 16:9. The same method works for any size: divide both sides by the same number until no whole number divides both of them. That is the whole method, and it is the same method a calculator, a spreadsheet and a piece of paper would use, which is why the answer is the same whichever way you check it.
Worked examples for aspect ratio in CSS
Worked examples make the maths concrete, so here are three you can check. First, 1920 by 1080 is 16:9, because both numbers divide by 120. Second, if you know the ratio is 16:9 and one side is 1280 pixels, the other side follows from the ratio: divide 1280 by the first part of the ratio and multiply by the second part, and you get the missing side without guessing. Third, resizing works the same way: if you halve the width, halve the height too, and the ratio stays 16:9. These three examples cover the three jobs this tool does — find the ratio, find a missing side, and resize — and every other size you meet is the same three jobs with different numbers. Try your own numbers in the tool above and check them against the examples in the table below.
A common mistake is to change only one side. If a picture is 1920 by 1080 and you change the width to 1000 pixels but leave the height at 1080, the ratio changes, the picture stretches, and the result looks wrong even if you cannot say why at first. The fix is simple: change both sides by the same factor, or use the resize mode of the tool, which does that for you. Another mistake is to trust a rounded decimal. The decimal 1.778 is a rounded version of the ratio, and for most work that is fine, but for exact work use the whole-number ratio 16:9 instead. A third mistake is to mix up width and height, especially for vertical formats, where the height is the larger number. Always check which number is the width before you calculate, and check the preview box under the tool, which shows the shape you are about to make.
Common sizes for aspect ratio in CSS
The table below lists the sizes web developers meet most often for responsive web layouts. It is a reference, not a rule: the right size depends on where the picture or video will be shown, and platforms change their recommended sizes, so verify the current size in the platform help centre before you publish anything important. What does not change is the ratio. A 16:9 video is 16:9 whether it is 1280 by 720, 1920 by 1080 or 3840 by 2160, and a 9:16 video is 9:16 whether it is 720 by 1280 or 1080 by 1920. That is why the ratio, not the pixel count, is the thing to remember. Keep this page bookmarked, and use the tool above whenever a size is not in the table, because the tool works for any numbers, not just the common ones.
When you read a size table, read it in three columns: the ratio, the pixel size, and where it is used. The ratio tells you the shape, the pixel size tells you the resolution, and the use tells you whether that size fits your job. For example, a thumbnail and a full video can share the ratio 16:9 while having very different pixel counts, and a square post and a square profile picture can share the ratio 1:1 while serving different purposes. Do not pick a size only because it is common. Pick the ratio that fits where the picture will be seen, then pick the pixel size that fits the quality you need, then check the result in the tool. That order — ratio first, pixels second — avoids most of the resizing problems people run into.
Common mistakes with aspect ratio in CSS
The most common mistake is stretching. It happens when a picture is forced into a frame with a different ratio, and the usual cause is a platform that crops or stretches automatically. The cure is to crop first, to the right ratio, and then resize. The second mistake is using a low-resolution original and enlarging it. Enlarging cannot add detail, so the picture goes soft, and no ratio tool can fix that. Start from the largest original you have, and resize down, never up, unless you have no choice. The third mistake is forgetting the safe zone, especially for video and social posts, where captions, buttons and profile pictures cover the edges. Leave space around the important part of the picture, and check it on a phone, because most people will see it on a phone first.
Another mistake is to copy a size from an old guide without checking the date. Platforms change their sizes, and a size that was right last year can be wrong now, especially for social media, where the recommended sizes for stories, reels and thumbnails are updated regularly. This guide is dated November 2026, and the sizes in it were correct then, but you should still verify the current size in the platform help centre before a big launch. A final mistake is to ignore file size. A very large image loads slowly, and a slow page loses readers, so export at the size you need and no larger, and use a modern format where you can. The ratio tool helps here too, because it lets you work out the smallest size that still looks sharp.
Choosing the right ratio for responsive web layouts
Choosing a ratio is a decision about where the picture will be seen. For responsive web layouts, ask three questions before you choose. First, where will people see it — on a phone held upright, on a computer screen, on a television, or on paper? A phone favours tall ratios, a television favours wide ones, and paper favours the ratio of the paper itself. Second, what is the most important part of the picture, and will it survive a crop to that ratio? If the important part is in the middle, most ratios will work; if it is at the edges, a wide or tall crop may cut it off. Third, what does the platform expect? A platform that expects 16:9 will crop or letterbox anything else, so it is usually better to give it 16:9 in the first place than to let it guess.
There is no single best ratio for every job, and that is why this site has a separate tool for each ratio and each use. A wide ratio suits a landscape, a film and a presentation on a big screen, while a tall ratio suits a phone, a story and a poster on a door. A square ratio suits a feed where every post is shown at the same size, and a 4:5 portrait suits a feed where a slightly taller post gets more space. The right choice is the one that fits the screen, keeps the important part visible, and matches what the platform expects. When you are not sure, make the picture in the ratio the platform asks for, and keep a copy in the original ratio as well, so you can remake it later without starting again.
How to use this aspect ratio in CSS, step by step
First, find the numbers you have. They may be the width and height of an image, the resolution of a video, or the diagonal size of a screen. Write them down, and check which one is the width and which one is the height, because swapping them gives the opposite ratio. Second, enter them in the tool above and press Calculate. Read the result, and check the preview box, which shows the shape. Third, decide what you need: the ratio itself, a missing side, or a new size at the same ratio. Use the mode that matches that job, and enter the one number you know. Fourth, check the answer against the table on this page. If the answer looks very different from the sizes in the table, check your numbers again, because a single wrong digit changes the ratio completely.
Fifth, export or save at the new size, and check the result before you publish it. Open the picture or video on the device where people will see it — usually a phone — and look at the edges, the text and the faces. If anything is cut off or stretched, go back to the tool, change the size, and try again. That loop — calculate, check, export, check again — takes a minute, and it is much cheaper than publishing the wrong size and having to remake it. Keep this page open while you work, and use the related tools linked below when the job changes, for example when you need the PPI of a screen or the print size of a photo.
Reference table
| Size | Ratio | Decimal | Used for |
|---|---|---|---|
| 1920 × 1080 | 16:9 | 1.778 | HD video, YouTube |
| 1280 × 720 | 16:9 | 1.778 | HD video, thumbnails |
| 1080 × 1920 | 9:16 | 0.562 | TikTok, Reels, Shorts |
| 1080 × 1080 | 1:1 | 1.000 | Square posts |
| 1080 × 1350 | 4:5 | 0.800 | Instagram portrait |
| 1200 × 630 | 1.91:1 | 1.905 | Link previews |
| 3000 × 2000 | 3:2 | 1.500 | DSLR photos |
| 1024 × 768 | 4:3 | 1.333 | Presentations |
aspect-ratio and object-fit: the pair that keeps images tidy
The CSS aspect ratio calculator answers the ratio question, but the ratio on its own only sizes the box. What goes inside the box is decided by object-fit, and the two properties are usually written together for a reason. Aspect-ratio says the box is 16:9, or 3:2, or square. Object-fit says how the image inside it behaves when its own shape does not match. Without object-fit, an image in a ratio box either stretches or leaves gaps. With it, the layout stays uniform even when the source files are a mix of shapes.
Object-fit has five values, and three of them do the real work. Cover uses the image's smallest dimension to fill the box and crops the rest, which is what you want for a grid of thumbnails where every cell must look the same size. Contain does the opposite: it shows the whole image, resized to fit inside the box, which leaves bars on two sides but loses nothing. Fill stretches the image to the box exactly, which squashes faces and should almost never be used on photographs. None crops the image at its natural size from the centre, and scale-down picks the smaller of none and contain. Cover is the default choice for image grids, contain is the default choice when no part of the image may be cropped, such as a product photo where a cut-off edge would hide a feature.
A worked example makes the pairing concrete. A sponsor grid built with display: grid and grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)) hands each cell whatever width is left after auto-fill works out how many fit. Put aspect-ratio: 1 / 1 and width: 100% on the img, plus object-fit: contain, and every logo in the grid sits in a square cell at the same size, regardless of whether the source logo is wide, tall or square. Swap contain for cover and the wide logos get cropped at the sides instead. The choice between the two is a content decision, not a styling preference, and it should be made per component rather than once for the whole site.
The same pairing fixes video embeds and iframes. A video container with width: 100% and aspect-ratio: 16 / 9 holds its shape at every viewport size, and the iframe inside it fills the container with width and height set to 100%. Before aspect-ratio existed, the same job needed a parent container with padding-top: 56.25% and an absolutely positioned child, because percentage padding resolves against the containing block's width. That trick still works, and it is still the fallback for older browsers, but it needs extra markup and extra positioning for something the property now says in one line. The video aspect ratio converter works out the ratio numbers for any embed, and the 16:9 calculator covers the most common video shape in detail.
Stopping layout shift with aspect-ratio and image attributes
The most valuable thing aspect-ratio does has nothing to do with how a page looks when it finishes loading. It decides how the page behaves while it is still loading. When an image arrives from a remote server with no size information, the browser gives it no space, and the content below it sits high on the page. When the image finally loads, everything below it jumps down. That jump is cumulative layout shift, and it is the reason a page can feel broken even when every asset eventually appears. A reader who was about to tap a link taps the wrong thing instead, and the page earns a poor stability score for it.
Aspect-ratio fixes the jump by reserving the space before the image arrives. Write img with width: 100% and aspect-ratio: 8 / 6, and the browser holds an 8 by 6 shaped space while the file downloads, so nothing below it moves. The same effect comes from the width and height attributes on the img tag itself, which is the recommended approach when you know the dimensions ahead of time. An 800 by 600 image gets width="800" height="600" in the markup, plus width: 100% and height: auto in the CSS, and the browser works out the ratio from the attributes even if the displayed size is different. You can even write width="8" height="6" and get the same ratio, because only the proportion matters, not the pixel values.
Aspect-ratio is a preferred ratio, not an absolute one, and that distinction explains most of the bugs people report. Setting both width and height explicitly can override the ratio, and content that overflows the box can force it taller than the ratio allows. The rule that avoids nearly all of it is to set one dimension and let the ratio decide the other. Give the element a width and aspect-ratio, and the height follows. Give it a height and aspect-ratio, and the width follows. Give it both, and the browser has to choose which instruction wins, which is where the surprises start. The same applies to the auto keyword: aspect-ratio: auto means a replaced element such as an img uses its own intrinsic ratio, and if you write auto together with a ratio, the specified ratio is the preference unless the element has an intrinsic one, in which case the intrinsic ratio wins.
For older browsers, the padding-top fallback is still worth knowing, because it is what every codebase written before 2021 is using. Wrap the modern rule in @supports (aspect-ratio: 1 / 1) and let everything else take the padding path, with height: 0 and padding-top set to the percentage for the ratio. The percentages are simple arithmetic: the height divided by the width, times 100. That gives 100% for 1:1, 75% for 4:3, 66.67% for 3:2, 56.25% for 16:9 and 177.78% for 9:16. Keep a table of them near the code rather than recalculating each time, and check the result at a narrow viewport, because a ratio that looks right on a laptop can still break when the container gets narrower than the content inside it.
| Ratio | aspect-ratio value | padding-top fallback | Common use |
|---|---|---|---|
| 1:1 | aspect-ratio: 1 / 1 | 100% | Square thumbnails, avatars |
| 4:3 | aspect-ratio: 4 / 3 | 75% | Classic photos, tablets |
| 3:2 | aspect-ratio: 3 / 2 | 66.67% | Camera photos, galleries |
| 16:9 | aspect-ratio: 16 / 9 | 56.25% | Video embeds, hero images |
| 21:9 | aspect-ratio: 21 / 9 | 42.86% | Ultrawide banners |
| 9:16 | aspect-ratio: 9 / 16 | 177.78% | Stories, reels, vertical video |
| 4:5 | aspect-ratio: 4 / 5 | 125% | Portrait feed posts |
| 2:3 | aspect-ratio: 2 / 3 | 150% | Portrait photos, pins |
aspect-ratio in real layouts: grids, cards and video embeds
The CSS aspect ratio calculator is at its most useful inside real layouts, where the ratio is not a single box but a rule applied to dozens of boxes at once. A grid of article cards is the classic case. Give each card a width from the grid, set aspect-ratio: 3 / 2 on the image area, and every card in the row has the same shape regardless of the source image, because the ratio is doing the sizing and object-fit: cover is doing the cropping. Change the grid from three columns to two at a breakpoint and the cards get wider, but the ratio holds, so the layout stays rhythmic instead of ragged. Without the ratio, each card's height follows its own image, and the grid looks like a set of mismatched tiles.
Flexbox benefits the same way. A row of sponsor logos in a flex container, each with aspect-ratio: 1 / 1 and width: 100%, stays square at every screen width, and the logos inside scale with the cell rather than fighting it. A calendar component with date cells at aspect-ratio: 1 keeps every day the same shape from a wide desktop month view down to a narrow phone view, which is the difference between a calendar and a list of uneven boxes. The ratio is doing layout work that used to need JavaScript measuring the container and setting heights by hand, and it does it at every resize without a single event listener.
Video embeds are the oldest use case and still the most common. A responsive iframe at 100 percent of its parent's width needs a height that stays 16:9, and aspect-ratio: 16 / 9 on the container gives it to you in one line, with the iframe inside set to width and height of 100 percent. Before the property existed, the same job needed a parent with padding-top: 56.25% and an absolutely positioned child, which worked but needed extra markup and was easy to break when someone edited the styles. The modern version is shorter, clearer, and easier to hand to the next developer, which is a real benefit on a codebase that will outlive its author.
Testing the layout is the last step, and it needs a narrow viewport, not just a wide one. Open the page at 360 pixels wide, the width of a small phone, and check that the ratio boxes hold their shape, that the images inside them are cropped rather than squashed, and that no text overflows its card. Then open it at 1440 pixels and check the same. A layout that only works at one width is not responsive, and the ratio is usually the first thing to break, because a container that is narrower than its content forces the box taller than the ratio allows. Fix it by separating the ratio box from the text content, as above, and the layout holds at every width in between.
There are limits worth knowing before you rely on the property everywhere. Aspect-ratio is a preferred ratio, so content that overflows the box can force it taller, and setting both width and height explicitly can override it. A card with a long title that wraps to three lines will grow taller than its ratio unless the content area is separated from the ratio box, which is why the usual pattern puts the ratio on the image wrapper and lets the text sit below it in normal flow. Minimum and maximum sizes interact too: a min-height on a ratio box can stretch it, and a max-width can shrink it, so test the layout at the narrowest viewport you support, not just the widest. The Reels and Shorts size calculator covers the 9:16 ratio these layouts often embed, and the video aspect ratio converter works out the numbers for any embed shape.
Tips
- Keep the ratio, change both sides by the same factor.
- Resize down from a large original, not up from a small one.
- Verify platform sizes in the platform help centre before publishing.
- Check the result on a phone, where most people will see it.
Related on Ratiqx: ppi calculator, app icon size calculator, social media image size calculator, ratio simplifier.
Authoritative sources: W3Schools — Aspect Ratio Calculator, MDN — aspect-ratio (CSS), MiniWebTool — Aspect Ratio Calculator.
The ratios you use most in CSS are 16:9 for video and 1:1 for squares, and the ratio simplifier reduces any width and height to the simplest ratio before you write the property.
Aspect Ratio in CSS: The aspect-ratio Property
Aspect Ratio in CSS: The aspect-ratio Property — Aspect ratio in CSS: the aspect-ratio property explained, with responsive examples.
How the aspect ratio in CSS works
The aspect ratio in CSS answers one question: what happens to the shape when the numbers change? For responsive web layouts, the shape matters as much as the size. A picture that is 1920 by 1080 pixels has the ratio 16:9, which is 1.778 as a decimal. That decimal is the width divided by the height, and it tells you at a glance whether the picture is wide, square, or tall. If you keep that decimal the same while you change the size, the picture keeps its shape. If you change it, the picture stretches, and people, faces and text look wrong. This tool does the arithmetic for you, so you do not have to work out the greatest common divisor by hand, and you can check a size in seconds before you export, upload or print it.
Start with the numbers you already have. For responsive web layouts, those numbers are usually the width and height in pixels, and they are shown in your editor, your camera settings, or the file details on your computer. Enter the width first and the height second, and the tool divides both numbers by their greatest common divisor. For 1920 and 1080, that divisor is 120, so 1920 divided by 120 is 16 and 1080 divided by 120 is 9, giving 16:9. The same method works for any size: divide both sides by the same number until no whole number divides both of them. That is the whole method, and it is the same method a calculator, a spreadsheet and a piece of paper would use, which is why the answer is the same whichever way you check it.
Worked examples for aspect ratio in CSS
Worked examples make the maths concrete, so here are three you can check. First, 1920 by 1080 is 16:9, because both numbers divide by 120. Second, if you know the ratio is 16:9 and one side is 1280 pixels, the other side follows from the ratio: divide 1280 by the first part of the ratio and multiply by the second part, and you get the missing side without guessing. Third, resizing works the same way: if you halve the width, halve the height too, and the ratio stays 16:9. These three examples cover the three jobs this tool does — find the ratio, find a missing side, and resize — and every other size you meet is the same three jobs with different numbers. Try your own numbers in the tool above and check them against the examples in the table below.
A common mistake is to change only one side. If a picture is 1920 by 1080 and you change the width to 1000 pixels but leave the height at 1080, the ratio changes, the picture stretches, and the result looks wrong even if you cannot say why at first. The fix is simple: change both sides by the same factor, or use the resize mode of the tool, which does that for you. Another mistake is to trust a rounded decimal. The decimal 1.778 is a rounded version of the ratio, and for most work that is fine, but for exact work use the whole-number ratio 16:9 instead. A third mistake is to mix up width and height, especially for vertical formats, where the height is the larger number. Always check which number is the width before you calculate, and check the preview box under the tool, which shows the shape you are about to make.
Common sizes for aspect ratio in CSS
The table below lists the sizes web developers meet most often for responsive web layouts. It is a reference, not a rule: the right size depends on where the picture or video will be shown, and platforms change their recommended sizes, so verify the current size in the platform help centre before you publish anything important. What does not change is the ratio. A 16:9 video is 16:9 whether it is 1280 by 720, 1920 by 1080 or 3840 by 2160, and a 9:16 video is 9:16 whether it is 720 by 1280 or 1080 by 1920. That is why the ratio, not the pixel count, is the thing to remember. Keep this page bookmarked, and use the tool above whenever a size is not in the table, because the tool works for any numbers, not just the common ones.
When you read a size table, read it in three columns: the ratio, the pixel size, and where it is used. The ratio tells you the shape, the pixel size tells you the resolution, and the use tells you whether that size fits your job. For example, a thumbnail and a full video can share the ratio 16:9 while having very different pixel counts, and a square post and a square profile picture can share the ratio 1:1 while serving different purposes. Do not pick a size only because it is common. Pick the ratio that fits where the picture will be seen, then pick the pixel size that fits the quality you need, then check the result in the tool. That order — ratio first, pixels second — avoids most of the resizing problems people run into.
Common mistakes with aspect ratio in CSS
The most common mistake is stretching. It happens when a picture is forced into a frame with a different ratio, and the usual cause is a platform that crops or stretches automatically. The cure is to crop first, to the right ratio, and then resize. The second mistake is using a low-resolution original and enlarging it. Enlarging cannot add detail, so the picture goes soft, and no ratio tool can fix that. Start from the largest original you have, and resize down, never up, unless you have no choice. The third mistake is forgetting the safe zone, especially for video and social posts, where captions, buttons and profile pictures cover the edges. Leave space around the important part of the picture, and check it on a phone, because most people will see it on a phone first.
Another mistake is to copy a size from an old guide without checking the date. Platforms change their sizes, and a size that was right last year can be wrong now, especially for social media, where the recommended sizes for stories, reels and thumbnails are updated regularly. This guide is dated November 2026, and the sizes in it were correct then, but you should still verify the current size in the platform help centre before a big launch. A final mistake is to ignore file size. A very large image loads slowly, and a slow page loses readers, so export at the size you need and no larger, and use a modern format where you can. The ratio tool helps here too, because it lets you work out the smallest size that still looks sharp.
Choosing the right ratio for responsive web layouts
Choosing a ratio is a decision about where the picture will be seen. For responsive web layouts, ask three questions before you choose. First, where will people see it — on a phone held upright, on a computer screen, on a television, or on paper? A phone favours tall ratios, a television favours wide ones, and paper favours the ratio of the paper itself. Second, what is the most important part of the picture, and will it survive a crop to that ratio? If the important part is in the middle, most ratios will work; if it is at the edges, a wide or tall crop may cut it off. Third, what does the platform expect? A platform that expects 16:9 will crop or letterbox anything else, so it is usually better to give it 16:9 in the first place than to let it guess.
There is no single best ratio for every job, and that is why this site has a separate tool for each ratio and each use. A wide ratio suits a landscape, a film and a presentation on a big screen, while a tall ratio suits a phone, a story and a poster on a door. A square ratio suits a feed where every post is shown at the same size, and a 4:5 portrait suits a feed where a slightly taller post gets more space. The right choice is the one that fits the screen, keeps the important part visible, and matches what the platform expects. When you are not sure, make the picture in the ratio the platform asks for, and keep a copy in the original ratio as well, so you can remake it later without starting again.
How to use this aspect ratio in CSS, step by step
First, find the numbers you have. They may be the width and height of an image, the resolution of a video, or the diagonal size of a screen. Write them down, and check which one is the width and which one is the height, because swapping them gives the opposite ratio. Second, enter them in the tool above and press Calculate. Read the result, and check the preview box, which shows the shape. Third, decide what you need: the ratio itself, a missing side, or a new size at the same ratio. Use the mode that matches that job, and enter the one number you know. Fourth, check the answer against the table on this page. If the answer looks very different from the sizes in the table, check your numbers again, because a single wrong digit changes the ratio completely.
Fifth, export or save at the new size, and check the result before you publish it. Open the picture or video on the device where people will see it — usually a phone — and look at the edges, the text and the faces. If anything is cut off or stretched, go back to the tool, change the size, and try again. That loop — calculate, check, export, check again — takes a minute, and it is much cheaper than publishing the wrong size and having to remake it. Keep this page open while you work, and use the related tools linked below when the job changes, for example when you need the PPI of a screen or the print size of a photo.
Why aspect ratio in CSS matters in practice
In practice, aspect ratio in CSS is not an abstract maths topic. It decides whether a picture fits the frame it is shown in, and whether the people in it look right. A creator who understands aspect ratio in CSS can plan a shoot, a design or a presentation around the frame, instead of discovering at the end that the picture does not fit. That planning saves time, because a picture made in the right ratio needs no emergency crop, and it saves quality, because a picture that is cropped after the event loses pixels that could have been kept. For responsive web layouts, the ratio is part of the brief, not an afterthought, and the tools on this site exist so that the arithmetic never gets in the way of that planning.
There is also a practical reason to learn the method, not just the answer. Tools change, platforms change their sizes, and a new format can appear at any time, but the method — divide both sides by their greatest common divisor — does not change. Once you can do it on paper for 1920 by 1080, which is 16:9, you can do it for any size, with or without a calculator. That is why this article shows the working, not just the answer, and why the examples use round numbers you can check. Keep the method in mind when you use the tool above, and check one answer by hand now and then, so you know the tool is giving you a sensible result.
Aspect Ratio in CSS: The aspect-ratio Property: what to check before you publish
Before you publish anything that depends on aspect ratio in CSS, check four things. First, check the ratio itself: is it really 16:9, or did a number get typed wrong? Second, check the pixel size: is it large enough for where it will be shown, and not so large that it loads slowly? Third, check the edges: is anything important cut off, covered by a caption, or hidden behind a button? Fourth, check the date: are the platform sizes in this guide still current? Platforms change their sizes, and this guide is dated November 2026, so verify the current size in the platform help centre before a big launch. Those four checks take a minute, and they catch most of the mistakes that make a good picture look unprofessional.
If a check fails, fix the ratio first and the pixels second. Change the ratio by cropping to the right shape, then resize to the pixel size you need, and check the edges again. Do not try to fix a wrong ratio by stretching the picture, because stretching changes every face and every line in it, and readers notice it even when they cannot name it. If you are not sure which ratio a platform wants, make the picture in that ratio and keep a copy in the original ratio as well. That way you can remake it later without starting again, and you have a clean original to fall back on if the platform changes its mind.
Reference table
| Size | Ratio | Decimal | Used for |
|---|---|---|---|
| 1920 × 1080 | 16:9 | 1.778 | HD video, YouTube |
| 1280 × 720 | 16:9 | 1.778 | HD video, thumbnails |
| 1080 × 1920 | 9:16 | 0.562 | TikTok, Reels, Shorts |
| 1080 × 1080 | 1:1 | 1.000 | Square posts |
| 1080 × 1350 | 4:5 | 0.800 | Instagram portrait |
| 1200 × 630 | 1.91:1 | 1.905 | Link previews |
| 3000 × 2000 | 3:2 | 1.500 | DSLR photos |
| 1024 × 768 | 4:3 | 1.333 | Presentations |
aspect-ratio in practice: the padding-top table
Before CSS had an aspect-ratio property, developers kept boxes proportional with the padding-top trick: percentage padding is calculated from the parent width, not its height, so padding-top of 56.25 percent makes a box exactly 16:9. The table below gives the percentage for each common ratio, so you can read it off instead of working it out. The formula is height divided by width, times 100.
| Ratio | padding-top | aspect-ratio value |
|---|---|---|
| 16:9 | 56.25% | 16 / 9 |
| 4:3 | 75% | 4 / 3 |
| 1:1 | 100% | 1 |
| 3:2 | 66.67% | 3 / 2 |
| 2:3 | 150% | 2 / 3 |
| 4:5 | 125% | 4 / 5 |
| 21:9 | 42.86% | 21 / 9 |
| 9:16 | 177.78% | 9 / 16 |
Today the modern way is one line: aspect-ratio: 16 / 9 with width: 100 percent, and the browser works out the height. It is supported in Chrome 88 and later, Firefox 89 and later, and Safari 15 and later, so the padding trick is only needed for older browsers. Two things to remember: aspect-ratio is a preferred ratio, not a forced one, so setting both width and height overrides it; and on images and video, pair it with object-fit: cover so the content fills the box instead of stretching. Work out any ratio first in the aspect ratio finder, and the pixel size of a 16:9 frame in the 16:9 calculator.
Tips
- Keep the ratio, change both sides by the same factor.
- Resize down from a large original, not up from a small one.
- Verify platform sizes in the platform help centre before publishing.
- Check the result on a phone, where most people will see it.
Authoritative sources: W3Schools — Aspect Ratio Calculator, MDN — aspect-ratio (CSS), MiniWebTool — Aspect Ratio Calculator.
Frequently asked questions
What is aspect ratio in CSS?
aspect ratio in CSS is the tool on this page. It takes the numbers you enter — for example 1920 by 1080, which is 16:9 — and works out the answer without changing the proportions. You do not need to sign up, and nothing is uploaded.
How do I use this aspect ratio in CSS?
Enter the numbers in the boxes above, then press the Calculate button. Check the result, and if you need a different size, change one number and calculate again. The answer updates straight away, in your browser.
Is this aspect ratio in CSS free?
Yes. This tool is free, with no sign-up and no download. You can use it as many times as you like, on a phone or a computer.
Why does the ratio 16:9 matter?
The ratio 16:9 is 1.778 as a decimal. If you change one side without changing the other by the same factor, the image or video stretches or squashes. Keeping the ratio keeps the picture looking right.
Can I use this on my phone?
Yes. The tool is mobile-first and works on a phone, tablet or computer. The buttons are large enough to tap, and the result is shown clearly under the tool.
How do I calculate aspect ratio in CSS?
Here is how to calculate aspect ratio in CSS: use the aspect-ratio property: aspect-ratio: 16 / 9; on the element. The browser works out the other side from the width or height you set. For older browsers, the padding-top trick gives the same result — see the CSS guide on this site.
What is the padding-top percentage for 16:9?
56.25 percent — 9 divided by 16 times 100. The padding-top trick uses height divided by width times 100: 75 percent for 4:3, 100 percent for 1:1, and 177.78 percent for 9:16. The modern aspect-ratio property replaces the trick in current browsers.
What is 56.25 percent in CSS?
It is the padding-top value that makes a box 16:9. 9 divided by 16 is 0.5625, so padding-top: 56.25 percent gives a box whose height is always 56.25 percent of its width. The modern replacement is aspect-ratio: 16 / 9.
Does aspect-ratio work on images?
Yes, and it is one of its best uses: setting width and height attributes on an image lets the browser reserve the right space before the file loads, which stops the page jumping. Pair it with object-fit: cover if the image must fill the box without stretching.
What happens if I set both width and height with aspect-ratio?
The ratio gives way. aspect-ratio sets a preferred ratio, not a forced one: if both dimensions are fixed, or the content is taller than the computed height, the browser uses the fixed sizes and the ratio is ignored.