CSS Aspect Ratio Calculator
Calculate CSS aspect ratios from width and height. Get simplified ratios, padding-bottom percentages, and ready-to-use CSS code snippets.
About
Miscalculating aspect ratios in CSS leads to stretched images, broken layouts, and content reflow that degrades Cumulative Layout Shift (CLS) scores. The aspect-ratio property and the legacy padding-bottom percentage technique both require a precise ratio derived from pixel dimensions. This tool computes the simplified ratio using the Euclidean GCD algorithm, outputs the decimal multiplier, generates the padding-bottom percentage for legacy browser support, and produces copy-ready CSS declarations. It also solves the inverse problem: given a target ratio and one known dimension, it calculates the missing dimension. Results assume rectangular geometry with no sub-pixel rounding applied.
Formulas
The simplified aspect ratio is found by dividing both dimensions by their Greatest Common Divisor (GCD). The GCD is computed recursively via the Euclidean algorithm:
The simplified ratio components become:
The CSS padding-bottom percentage for the legacy responsive box technique is:
For dimension scaling, given a target ratio R = Rw:Rh and a known width W:
Where W = width in pixels, H = height in pixels, Rw = ratio width component, Rh = ratio height component, P = padding-bottom percentage.
Reference Data
| Name | Ratio | Decimal | Padding-Bottom | Common Use |
|---|---|---|---|---|
| Square | 1:1 | 1.0000 | 100% | Social media avatars, thumbnails |
| Classic Photo | 3:2 | 1.5000 | 66.667% | DSLR photos, 35mm film |
| Standard TV | 4:3 | 1.3333 | 75% | Legacy monitors, iPad display |
| Photo Print | 5:4 | 1.2500 | 80% | 8×10 prints, medium format |
| European Widescreen | 5:3 | 1.6667 | 60% | Some phone screens |
| Widescreen HD | 16:9 | 1.7778 | 56.25% | YouTube, monitors, HDTV |
| Tall Widescreen | 16:10 | 1.6000 | 62.5% | MacBook displays, WUXGA |
| Phone Portrait | 9:16 | 0.5625 | 177.778% | Stories, Reels, TikTok |
| Ultrawide | 21:9 | 2.3333 | 42.857% | Ultrawide monitors, cinema |
| Super Ultrawide | 32:9 | 3.5556 | 28.125% | Samsung super ultrawide |
| Cinemascope | 2.35:1 | 2.3500 | 42.553% | Anamorphic cinema |
| IMAX | 1.43:1 | 1.4300 | 69.93% | IMAX film format |
| Univisium | 2:1 | 2.0000 | 50% | Modern phones (18:9), Netflix |
| Golden Ratio | 1.618:1 | 1.6180 | 61.804% | Design compositions |
| DCI 2K | 256:135 | 1.8963 | 52.734% | Digital cinema projection |
| A4 Paper | 1:√2 | 0.7071 | 141.421% | ISO 216 paper (A-series) |
| Instagram Landscape | 1.91:1 | 1.9100 | 52.356% | Instagram landscape posts |
| Instagram Portrait | 4:5 | 0.8000 | 125% | Instagram portrait posts |
| Twitter Card | 2:1 | 2.0000 | 50% | Twitter/X summary card images |
| OG Image | 1.905:1 | 1.9050 | 52.493% | Open Graph (1200×630) |