-
Notifications
You must be signed in to change notification settings - Fork 697
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. |
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. |
What is blocking us here now?
Is it the above? If yes, can't we "just" do the following?
Making a distinction between property/descriptor seems acceptable, especially with recent developments in CSSOM. |
Just a thought: if |
@benface |
Instead of naming it as size, we should name it length. For example, |
The CSS Working Group just discussed
The full IRC log of that discussion<TabAtkins> fantasai: wow this was old.<TabAtkins> fantasai: not clear what to do here, but people want it solved <TabAtkins> fantasai: complication is there's an existing size proeprty in @page rules <TabAtkins> fantasai: and it's not equivalent to setting width/height <TabAtkins> fantasai: width/height apply to the page area <TabAtkins> fantasai: this is implemented by PDF renderers <TabAtkins> fantasai: added this after chatting with emilio, who suggested maybe we just treat 'size' in @page specially, so they set a different size property, while everywhere else it's a shorthand <oriol> q+ <fantasai> https://github.com//issues/820#issuecomment-810626883 <TabAtkins> fantasai: so wanted to know if it's viable <ntim> i like the idea <TabAtkins> astearns: seems a little icky to have different processing based on where 'size' comes up <JoshT> q+ <TabAtkins> astearns: but maybe in this case its' reasonable <emilio> q+ <TabAtkins> (I think there's not really any better solution. Also slightly icked but okay with it for the benefit.) <astearns> ack oriol <TabAtkins> florian: Yeah, unfortunate, but since the weirdness is so scoped it's probaqbly okay <TabAtkins> oriol: in @page, it has descriptors not properties <JoshT> q- Was going to make the same point <TabAtkins> oriol: so a name conflict isn't *great* but not a big deal technically. can just say that 'size' descriptor and 'size' shorthand are different <JoshT> q- <astearns> ack emilio <ntim> q+ <TabAtkins> emilio: i think this is the onlyw ay to make it work <TabAtkins> emilio: but maybe it could be cool to make 'size' in @page a legacy alias for some other name, like 'page-size'? <TabAtkins> emilio: that would be easier to implement, I think, then I don't need to deal with the name conflict as much. <florian> +1 <TabAtkins> emilio: and maybe less confusing long term <TabAtkins> astearns: do you have a mechanism to only apply an alias in one at-rule context? <TabAtkins> emilio: yes, easily <TabAtkins> emilio: just within the @page descriptor, if descriptor name is 'size' return 'page-size' <astearns> ack fantasai <Zakim> fantasai, you wanted to reply to emilio <ntim> p+ <fantasai> https://github.com//issues/820#issuecomment-544582026 <TabAtkins> fantasai: we'd previously resolved to make it an alias and have page-size be the name <TabAtkins> fantasai: response we got was some products support JS and 'size' has been supported as long as PDF renderers have existed <TabAtkins> fantasai: so we could do aliasing, but would have to make sure it doesn't break CSSOM <TabAtkins> emilio: yeah, aliases already work nicely for that <astearns> ack ntim <TabAtkins> ntim: any usage data on 'size'? i guess elika has answered the question <TabAtkins> ntim: any browser have data? <TabAtkins> fantasai: primary usage isn't in browsers, it's in pdf renderers. so big market difference in both content and userbase <TabAtkins> emilio: i think browsers do support 'size' in printing, it's fairly used <TabAtkins> iank_: yeah people generate PDFs from brwosers all the time, and do use the 'size' descriptor <TabAtkins> iank_: so the markets are acteually pretty overlapping <TabAtkins> florian: and epub readers too <TabAtkins> florian: at least notionally, interactive pages user agents <TabAtkins> ntim: common on web sites tho? <TabAtkins> florian: when you print a web site, yeah, reasonably <TabAtkins> iank_: very common in enterprise use-cases to have printable pages <TabAtkins> iank_: and they use @page on those <fantasai> https://www.w3.org/TR/css-cascade-5/#aliasing <TabAtkins> ntim: i ask because in webkit, @page is pretty poorly maintained and we haven't seen many bug reports <TabAtkins> iank_: I suspect we have the best support among browsers here, and enterprises are just targetting Chrome for printing webapps <TabAtkins> astearns: so proposed resolution is we add 'size' shorthand proeprty that has nothing to do with '@page/size' <TabAtkins> astearns: concerns? <TabAtkins> RESOLVED: Add a 'size' shorthand property (for 'width'/'height'), no relation to @page's 'size' descriptor <TabAtkins> ntim: woudl longhand be physical or logical <TabAtkins> fantasai: i think would have to be physical because that's how we generally handle shorthand properties with both directions <TabAtkins> fantasai: we map to the physical directions by default <TabAtkins> florian: would be good to have a switch but we dont' have yet <TabAtkins> ntim: possible confusion with inline-size/block-size, versus width/height <TabAtkins> ntim: but otherwise fine with this <TabAtkins> emilio: should we discuss the alias in @page? <TabAtkins> astearns: separate issue <TabAtkins> emilio: i'll file one |
should |
This means that this version of |
Only for
|
That was asked in the call as well. It would need to be width and height, to follow the president set by other shorthands like
@emilio has filed #11925 to make a new property to replace |
If we do alias |
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: