A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/w3c/csswg-drafts/issues/4954 below:

[css-values-4] Ratio of `0/0`? · Issue #4954 · w3c/csswg-drafts · GitHub

So, the old <ratio>, since it only allowed integers, could meaningfully restrict its values to "greater than zero", so all ratios you could write were meaningful.

Now that we've relaxed it to <number>, we can't do that - can't do open ranges. So 0 is allowed.

And mostly that's fine! A ratio of 0/1 is just infinitely tall; a ratio of 1/0 is infinitely wide; CSS is okay with infinities. The "division results" are well-defined too - 0 and infinity, respectively.

But what about 0/0? We can't reject this at parse-time, since a calc() might be hiding a 0. But it definitely doesn't have a meaning; the division result is NaN.

Two possibilities I see:

  1. Define that it produces an "invalid ratio", and places that take <ratio> have to define what that means. The 'aspect-ratio' property would define that it doesn't give an aspect ratio (same as "none"); the (aspect-ratio) MQs would define that it always fails to match.

  2. Make it act the same as calc(0/0): it produces a NaN, which is censored into an infinity, so it's the same as saying 1/0 for the ratio.

I'm mildly leaning toward option 2. It's more consistent with 0/0 in general, and it means we don't need to ensure that every place that uses <ratio> defines what an "invalid ratio" does.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.3