What is Aspect Ratio Placeholder Calculator?
Aspect-ratio is a CSS property that sets a preferred aspect ratio for an element, letting the browser calculate the height from the width before content loads. This prevents Cumulative Layout Shift (CLS), a Core Web Vitals metric that measures visual stability. By reserving the correct space for images, videos, and embeds ahead of time, the page layout stays stable as resources load.
Quick answer
Calculate the CSS aspect-ratio value and padding-bottom fallback percentage to prevent Cumulative Layout Shift. Reserve the correct space for images, videos, and embeds before they load.
Limitations
- The padding-bottom fallback technique requires position: relative on the parent container and position: absolute on the child element for correct sizing behavior.
- Aspect-ratio only works when the element has a defined width. If the element width is auto or not set, the aspect-ratio calculation has no basis to compute the height.
How to use this tool
- Select a preset ratio such as 16:9, 4:3, or 1:1, or enter custom width and height values.
- View the generated aspect-ratio CSS value for modern browsers.
- Copy the padding-bottom fallback for browsers that do not support the aspect-ratio property.
- Apply the wrapper markup to your image or embed element. The placeholder reserves the correct height before the resource loads.
What you can use it for
- Reserve space for hero images on blog posts so the layout does not jump when the image loads.
- Create stable video embed containers for YouTube or Vimeo iframes that preserve the player aspect ratio.
- Build placeholder boxes for lazy-loaded images in a gallery grid.