w3c / csswg-drafts

CSS Working Group Editor Drafts
https://drafts.csswg.org/
Other
4.48k stars 659 forks source link

[css-align] the `start` keyword should be unambiguously defined as the inline-start / block-start side. #6186

Open dholbert opened 3 years ago

dholbert commented 3 years ago

In https://github.com/web-platform-tests/wpt/issues/28378 , it came to light that there's some ambiguity in the alignment spec about what the start keyword actually means, in the context of a flexbox. (Similar for end.) I think the spec intends to define it unambiguously, and it sort-of does if you have enough additional context, but it's worded such that a reader could reasonably come away with the wrong interpretation.

It's defined as follows, in css-align section 4.1:

start (self, content) Aligns the alignment subject to be flush with the alignment container’s start edge in the appropriate axis.

https://drafts.csswg.org/css-align/#valdef-self-position-start

Concerns: (1) the spec is defining "start" in terms of itself ("the start edge"), which isn't especially illuminating. :) (2) for a flexbox, the current spec text definition could be misinterpreted as meaning "the main-start or cross-start edge" (if you interpret "the appropriate axis" as e.g. "the main axis", and then reasonably infer that "the start side" of that axis is the main-start side). This isn't the spec's intended meaning (otherwise start and flex-start would be identical in a flexbox), but that's not unambiguously clear right now.

SUGGESTION: This probably wants s/start edge/block-start edge or inline-start edge/, or a similar clarification to make it clear (since the terms "inline-start" and "block-start" are unambiguously defined, and that makes it clear that this isn't talking about e.g. the main-start/cross-start edges.)

dholbert commented 3 years ago

I think the existing spec text is intended to be grounded in https://www.w3.org/TR/css-writing-modes-3/#start which says:

Where contextually unambiguous or encompassing both meanings, the terms start and end are used in place of block-start/inline-start and block-end/inline-end, respectively.

But I think it's worth being explicit and not using this shorthand terminology in this bit of css-align, because it's so easy to read "the start edge in the appropriate axis" as e.g. meaning "the main-start edge" in a case where that the appropriate axis is the main axis.

tabatkins commented 3 years ago

(1) the spec is defining "start" in terms of itself ("the start edge"), which isn't especially illuminating. :)

Well that's not circular, it's just straightforward. The "start" keyword aligns you to the start side. ^_^

(2) for a flexbox, the current spec text definition could be misinterpreted as meaning "the main-start or cross-start edge"

Right, Writing Modes is clear that the "start" direction can only refer to block-start or inline-start; all other logical directions must be prefixed with their axis.

While we could add more detail here, we use the unprefixed "start" and "end" terms thruout the specs, and I'd prefer not to have to expand every single one of them to say "inline-start or block-start"; the purpose of the shorthand in the first place was to make things more readable. Maybe we can just linkify harder?

dholbert commented 3 years ago

Yeah, I don't think we need to elaborate everywhere these terms are used. It'd just be useful to be extra-clear here, since there's such an easy/reasonable misreading within reach. ("start edge in the appropriate axis" --> "start edge of the main axis" --> "the main-start edge")

And yeah, "extra clear" could be achieved by linkifying the word "start" to its definition in https://www.w3.org/TR/css-writing-modes-3/#start (which again, doesn't need to happen everywhere IMO, but would be particularly useful here)

dholbert commented 3 years ago

(1) the spec is defining "start" in terms of itself ("the start edge"), which isn't especially illuminating. :)

Well that's not circular, it's just straightforward. The "start" keyword aligns you to the start side. ^_^

I suppose that's fair. Nonetheless, it feels circular for someone who doesn't know that "start" has a special more-precise-than-one-might-think meaning. (Particularly in this context where there are multiple other "-start" edges that this usage does not* mean to include, like cross-start and main-start).

Anyway: linkification would nicely break out of the (perceived) circular nature of this justify/align start keyword's definition.