Re: [csswg-drafts] [css-viewport] Behavior of `segments` when there is only 1 segment (#11957)

> We don't want authors to write code against one segment because they should treat that case as the same as if there wasn't any split (meaning the device is used flat in the case of a foldable) or it's just a regular device.

It’s not about writing code against 1 segment, but about consistency when enumerating the segments. We keep saying “1 segment” but that does not rhyme with `null`.

> Finally, not returning a single segment match the CSS part of this API where the MQs do not resolve for a value of one segment.

Which MQ are you talking about? AFAIK there is only the `device-posture` media feature and some env-vars that people can use. 

---

I asked on social media ([bsky](https://bsky.app/profile/bram.us/post/3lmkjrn2krk22), [masto](https://front-end.social/@bramus/114320482257497495)) what developers think about this:

> 📊 Poll time: say there is an API to enumerate how many segments the viewport has. E.g. for a foldable phone the number would be 2 when the device is unfolded.
> 
> What would you expect this API to return when the foldable is closed, or when it’s a non-foldable device?
> 
> A. null
> B. 1
> C. ???

There was an overwhelming for answer B: 1 segment.

-- 
GitHub Notification of comment by bramus
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/11957#issuecomment-2808322277 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 16 April 2025 05:15:07 UTC