New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[css-sizing] Adding a 'size' shorthand for 'width'/'height' #820
Comments
dimensions (probably too long and difficult to spell) I've added this to the list of mistakes |
Also, just to put it out there, how bad would it be if we added this under the On the one hand, this is dirty and there is no precedent for properties meaning completely different things in different context, on the other hand, the usages seem really disconnected, and authors would likely cope just fine. (and on the third hand, it isn't entirely clear why |
|
Not |
I don't see the benefit. I'd rather not pollute the property space with property names that yield little benefit. If you want to set both, then just set both. p.s.: What would be more interesting is aspect-ratio values for height and width (behaving similar to auto, insofar as that they will scale when one value is set or the other). |
Without added features beyond a shorthand, such a new property would be nonsense anyway.
PS: Maybe |
What would take precedence if width/height and I'd argue something like this would make sense: .block {
height: 640px; /* change this through MQ */
width: 480px; /* change this through MQ */
}
img.some {
display: block;
width: 100%;
height: aspect(0.5); /* set's the height to half of the width */
height: auto(0.5); /* set's the height to half of the width */
height: auto-aspect(0.5); /* set's the height to half of the width */
height: aspect-ratio(0.5); /* set's the height to half of the width */
height: aspect-ratio(golden); /* set's the height to golden cut */
height: aspect-ratio(calc(9/16)); /* set's the height to 16:9 */
} |
This topic is not about a theoretical aspect-ratio property; please move any such discussion to a different issue. (There might already be one started for that.) |
@tabatkins so on the constructive side: |
The issues are connected however, @tabatkins, because it could make sense to name them all
|
@Crissov then the rule would be whatever is set as a property (with the same or higher specificity, obviously) overwrites each other? E.g. would this hold true? div {
dimensions: 100px 200px; /* width: 100px, height 200px */
width: 50px; /* width: 50px, height: 200px */
dimensions: 100px; /* width: 100px, height: 200px */
/* Related / Off-Topic: */
dimensions: 100px aspect-ratio(calc(9/16)); /* width: 100px, height: 56.26px */
} |
I'd say that a single length makes the box square – assuming 1:1 is the default aspect ratio that the shorthand resets to: It could also keep the current AR, hence Alas, then Otherwise, yes |
@inoas Precedence is calculated by the cascade, as @Crissov As Tab said, please take discussion of aspect ratios elsewhere. This issue is literally just a naming conflict issue. |
@inoas Oh, as for the benefit: there are many times when one wants to set both width and height, or both min/max-width and min/max-height, to the same thing. It's not commonly desired for length values (since that would always make a square), but for keywords and percentages it is. |
@fantasai The detour to aspect ratios was necessary, for me at least, to prefer |
It would be |
@fantasai Thanks for pointing to the shorthand block. I just wasn't aware of the nomenclature. That clears the conflicting (that isn't there!). Edit: |
Are there other concerns with @frivoal’s suggestion that the |
@inoas The similarity of
or, of course,
|
Note also that |
Conclusion from today's call: currently tabling this issue. We can unblock it with:
|
What does implementor interest look like? Are outsiders (those who don’t work with browser vendors) capable of helping in this area? If an implementor is interested, how blocking is the later issue. I’m just not clear if this is an either/or list. |
It's an either/or list. If we can come up with a name that isn't 'size' that is really good for the author experience, then it's relatively easy to spec and implement. Or if there is enough author convenience in a shorthand named 'size' that convinces implementors to take it on, we can progress with that name. My understanding (as a non-implementor) is that this approach is slightly more complicated, and no one has (yet) considered this shorthand worth the effort to implement. Bugs, blog posts and bribes are needed. |
I have another concern for serialization. If we add div {
width: 200px;
height: 100px;
} would suddently be serialized to something like Code may be broken if they rely on parsing the serialization themselves. Not sure how usual this can be, though. |
We also hope for more parties commenting on this. Maybe adding If it is any help, we found that of 4 user agents that support
Returning 2 lengths, even after setting an identifier, looks like the best solution to us. Most script authors that have to retrieve the On the other hand, to keep the identifier if (and only if) it has been set, would be possible, but require passing it to |
Paper size approximationRegarding standard page sizes being stored with the canonical unit Many PDFs exhibit a similar issue, wherein ISO page dimensions have been converted to an integer number of DTP points, resulting in 297.04 mm × 209.9 mm for instance. However, ISO 216 specifies tolerances for cut paper sizes that are well beyond such rounding effects: ±1 mm for the sizes that have keywords in CSS if I remember correctly. Also, the sizes are iteratively rounded (floored?) from theoretical √2-based values to an integer number of millimeters anyway. The theoretical size of A4 would be about 297.302mm × 210.224mm or ca. In other words, if width and length are within 1mm of an ISO size after having been converted from a New
|
Wouldn't it be more convenient to make reductions for all properties at once?
|
|
@Crissov You can use |
Diagonals would of course only make sense if one could also set the aspect ratio within
|
I'm downloading AH Formatter right now (well, I'm requesting a trial download, we'll see), so I can see what they actually do with 'width'/'height' on pages, per @bernhardf-ro's comment that they're the only implementor that has those descriptors at all, and they do something different than the spec anyway. Changing the definition of @page/width and @page/height seems like the most viable way forward here, since no one's come up with a reasonable alternate name for 'size'. |
Would there be a need for |
Using Sebastian |
Note that |
I see this issue now has the tag Needs Design / Proposal. What might that design or proposal look like? Would it look like a new issue with the proposed changes as they might appear in a bikeshed document? Or as a PR? Perhaps some of us can help with this. |
I am not opposed to changing the definition of @page/width and @page/height. However, we still need a way to specify the width and height of the page-area. For example, what about the following new syntax? ( @page {
size: A5;
margin: auto;
@page-area {
width: 32rem;
height: 29rlh;
}
} BTW, our implementation, Vivliostyle, has supported @page/width and @page/height in the same way as Antenna House Formatter since 2015. See our sample stylesheet using width and height on |
I chatted with @emilio about this back in December. IIRC, it seems it's possible to just have @MurakamiShinyu @faceless2 What do you think? |
@fantasai I agree that would be the best option, to keep the current definitions in |
It's not ideal, but I agree it's probably the simplest option. |
Isn’t |
We discussed this internally again and still think that just making |
CSS Grid has a |
Maybe I am missing something here, but can't @page {size} just get ignored if the values are in (px, em, rem, %, etc) and vise versa for block {size} if the values are in (A5, A4, Letter, mm, in, etc) |
Specs do not seem to preclude handling it specially. CSS Syntax requires that a CSS rule taking From this perspective, I do not see where CSSOM prevents a context-specific handling (even if Fwiw, what confuses me is not that a property grammar could be different depending on the context, but it is this differentiation between property and descriptor, which I cannot find in any other language, and to support |
It's largely a legacy separation. For whatever reason, the original editors thought it was valuable to draw a distinction between the two, and we've continued with it since then. |
Many people thruout the years have requested a 'size' property as a shorthand for 'width' and 'height', for the common cases when you want to set them both to the same value. (Either making the element square, or making it a similar rectangle to the containing block with percentages, or using the same keyword for both.)
This seems mildly useful, but it has a naming problem - the @page rule already has a 'size' property, and it's not a shorthand for the 'width' and 'height' properties @page also has. ('size' sets the size of the margin box, while 'width' and 'height' set the content box.)
Other suggestions for names?
The text was updated successfully, but these errors were encountered: