<ratio>

You’re reading the English version of this content since no translation exists yet for this locale. Help us translate this article!

The <ratio> CSS data type, used for describing aspect ratios in media queries, denotes the proportion between two unitless values.

Syntax

In Media Queries Level 3, the <ratio> data type consisted of a strictly positive <integer> followed by a forward slash ('/', Unicode U+002F SOLIDUS) and a second strictly positive <integer>. Spaces before and after the slash are optional. The first number represents the width, while the second represents the height.

In Media Queries Level 4, the <ratio> date type is updated to consist of a strictly positive <number> followed by a forward slash ('/', Unicode U+002F SOLIDUS) and a second strictly positive <number>. In addition a single <number> as a value is allowable.

Examples

Use in a media query

@media screen and (min-aspect-ratio: 16/9) { ... }

Common aspect ratios

Ratio Usage
Ratio4_3.png 4/3 Traditional TV format in the 20th century.
Ratio16_9.png 16/9 Modern "widescreen" TV format.
Ratio1_1.85.png 185/100 = 91/50 The most common movie format since the 1960s.
Ratio1_2.39.png 239/100
 
"Widescreen," anamorphic movie format.

Specifications

Specification Status Comment
Media Queries Level 4
The definition of '<ratio>' in that specification.
Candidate Recommendation
Media Queries
The definition of '<ratio>' in that specification.
Recommendation Initial definition.

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
<ratio>Chrome Full support 3Edge Full support 12Firefox Full support 3.5IE Full support 9Opera Full support 9.5Safari Full support 4.1WebView Android Full support ≤37Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support YesSafari iOS Full support 4.2Samsung Internet Android Full support 1.0

Legend

Full support  
Full support

See also