Csswg-drafts: [css-sizing] Golden Ratio keyword in 'aspect-ratio'

Created on 14 Jul 2020  ·  3Comments  ·  Source: w3c/csswg-drafts

Since <ratio> includes <number> now #3757, authors can use irrational values in 'aspect-ratio', e. g. calc((1 + sqrt(5)) / 2) yielding the Golden Ratio of c. 1.618. If phi was not accepted to be added as a predefined numeric constant #4702, it would be convenient to have it available as a classic keyword, e.g. golden or golden-ratio, in this property for the reasons provided in that issue already.

Closed Rejected as Wontfix by Editor Discretion css-sizing-3 css-sizing-4

Most helpful comment

I think in this case, the modicum of convenience doesn't justify the introduction of a (single) keyword in the aspect-ratio syntax, given that <number> covers that pretty well with a --phi custom property. While it has had an enduring appeal throughout the ages, it's just one of the many common aspect ratios. Beyond convenience, a keyword signals endorsement.

All 3 comments

I think in this case, the modicum of convenience doesn't justify the introduction of a (single) keyword in the aspect-ratio syntax, given that <number> covers that pretty well with a --phi custom property. While it has had an enduring appeal throughout the ages, it's just one of the many common aspect ratios. Beyond convenience, a keyword signals endorsement.

Iʼd be the last person to oppose additional useful keywords, but most common ones are easily and correctly represented by a decimal floating point number or a vulgar fraction as supported.

I already explained why variables make no sense for universally understood constants and that the Golden ratio is slightly more complex than, say, sqrt(2), both in #4702.

For the same reasons as stated in previous threads, I oppose adding this for now. The precise value of the golden ratio has no specific meaning or significance in layouts; in practice it's actually just "rectangles that are approximately 3:2 usually look pretty good". At absolute most, specifying a ratio of 1.6 / 1 adequately addresses this, and asking authors to write their values with that degree of precision is completely reasonable.

If there are ever reasons why authors do need the precise value of the golden ratio, and it's believably common enough to be worth the (relatively small) spec/implementation/testing burden, we can consider adding it. But no such reason has been presented yet, so I'm going to close this issue.

Was this page helpful?
0 / 5 - 0 ratings