Recommended Free Tools
Set aspect-ratio to describe a box’s preferred width-to-height proportion—for example, aspect-ratio: 16 / 9; for a widescreen shape. It helps determine an automatic dimension; it does not override an element when both its width and height are explicitly set.
What aspect-ratio does
The ratio is width divided by height. Thus, 16 / 9 means sixteen parts wide for every nine parts high, while 1 means 1 / 1, or a square. The property supplies a preferred ratio to sizing calculations; it is not a command to set two fixed dimensions. The browser can use it when at least one relevant dimension is automatic, subject to other layout constraints. See MDN’s aspect-ratio reference.
As an Amazon Associate I earn from qualifying purchases.
Basic syntax and responsive examples
The property accepts auto, a ratio, or both. Its initial value is auto, and it is not inherited. A ratio is written as width, slash, then height; if the denominator is omitted, it defaults to 1.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →/* Square box */
.square {
aspect-ratio: 1;
}
/* Widescreen region: the container determines width */
.video-frame {
width: 100%;
height: auto;
aspect-ratio: 16 / 9;
}
/* Natural ratio for replaced content when available;
otherwise use the preferred 3:4 ratio */
.media {
aspect-ratio: auto 3 / 4;
}
For a non-replaced element such as a div, a common pattern is to let the containing layout determine its width and leave height automatic. The ratio can then contribute a preferred height. For example:
#1 Best Overall
- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
.card {
width: 100%;
aspect-ratio: 4 / 3;
}
As the available width changes, the preferred sizing helps the card retain a 4:3 shape. This is not a guarantee that every final rendered box will have that exact shape: other sizing constraints and layout rules can affect its used dimensions. The practical behavior for different kinds of content is described in MDN’s guide to understanding and setting aspect ratios.
When the ratio affects size—and when it does not
- One dimension is automatic: the declared ratio can help calculate that dimension from the other one.
- Both width and height are explicitly set: the preferred ratio does not replace those specified sizes.
- Other layout constraints apply: min/max sizes and the surrounding layout can influence the final used dimensions.
To preserve a shape responsively, make sure the dimension you expect the ratio to determine is not independently fixed. If both dimensions are fixed by your CSS or layout, changing aspect-ratio alone will not make the box resize to match it.
Rank #2
Using aspect-ratio with images and other replaced content
Images and similar replaced elements can have an intrinsic ratio supplied by their content. The value auto uses a natural ratio when one exists. A combined declaration such as aspect-ratio: auto 3 / 4 uses the natural ratio for replaced content when available, with the specified ratio serving as the preferred ratio otherwise.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Keep the element’s box sizing separate from how its content is displayed. A preferred ratio affects sizing calculations; it does not by itself promise that an image will be stretched or cropped to fill the box. Content fitting or cropping is a separate styling decision.
Account for box-sizing
Ratio calculations use dimensions associated with the element’s box-sizing. If you are matching a visual width and height precisely, check whether the relevant sizing includes or excludes padding and borders under your chosen box-sizing rule. A mismatch between the dimensions you expect and the box being sized can make the result appear off-ratio.
Troubleshooting unexpected proportions
- The box ignores the ratio: check whether both width and height are explicitly specified. Leave the dimension you want calculated automatic.
- The box is close, but not exact: inspect other layout constraints and min/max sizing that can affect the final dimensions.
- An image does not fill or crop as expected: distinguish the image element’s box ratio from the image content’s intrinsic ratio; content fitting is a separate concern.
- Padding or borders change the apparent result: verify
box-sizingand which box dimensions are being compared.
Or skip the browser setup
If you need a screenshot of a page showing your CSS change, you can use ScreenshotNeo’s screenshot API instead of setting up a browser capture script. One GET request returns a screenshot; the request below saves a WebP image of the target page. See the ScreenshotNeo API documentation for request options.
Quick Recap
Best Value
Rank #4
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
ScreenshotNeo accepts cookie or consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each of those steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers report the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The Free plan includes 1,000 screenshots per month with no card required; paid plans start at $5 for 3,000 screenshots. Learn about ScreenshotNeo or sign up free for 1,000 screenshots a month, with no card.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




