Clarify flex shorthand one-value syntax cases
Description
Updated the one-value syntax section for the flex property to clarify when values are interpreted as <number> vs. <width>, and which of flex-grow and flex-basis will be set based on the interpretation.
Motivation
When reading this section, I was confused about the differences between <number> and <width> before realizing that the latter needed to be a valid value for the CSS width property (e.g. 0 would be interpreted as a <number> whereas 0px would be interpreted as a <width>). I've added "unitless" before the <number> and a link to the width page to clarify this.
It was also not apparent which of the three flex properties would be set based on whether <number> or <width> was provided, so I broke it down into three bullet points to clarify this.
These changes can help readers understand the one-value syntax for flex at first glance (improved skimmability).
Additional details
Related issues and pull requests
Preview URLs
Flaws (1)
URL: /en-US/docs/Web/CSS/flex
Title: flex
Flaw count: 1
- macros:
The fourth to sixth parameters of 'EmbedLiveSample' are deprecated
(this comment was updated 2022-11-12 23:58:25.355866)
I tried to match the formatting of the two-value syntax section which has whitespaces before and after nested bullet points, but it looks like it's failing the linter.
Should I remove the extra whitespaces I've added?
Misinterpreted the linter error: updated to remove the trailing whitespaces in the empty lines between nested bullets.
Absolutely sensible to me @wbamberg, thank you for the clear explanation!
I like the accuracy of your suggestion, can we also include how the shorthand is expanded? e.g. in the current description, we have
a
<width>: In this case it is interpreted asflex: 1 1 <width>
I like this because it's explicit about the value of each of the flex properties, since flex is just a shorthand. However, as you've explained, it's not quite accurate because of the differences between width and flex-basis.
Would this be a fair combination of the explicitness of my initial changes and the accuracy of your suggestions?
One-value syntax: the value must be one of:
- a
<number>: then it is interpreted as flex-grow and expands toflex: <number> 1 0. - a
<width>or the keywordcontent: then it is interpreted as flex-basis and expands toflex: 1 1 (<width> | content). - the keyword
noneor one of the global keywords.
I've dropped the sub-bullets in my initial changes to be more concise since the Constituent properties section already describes the format of the shorthand (though this reduces the skimmability).
I'd also replace the instances of "a valid value for width" in the two and three-value syntax sections with "a valid value for width or the keyword content" to keep everything consistent and accurate.