-
Notifications
You must be signed in to change notification settings - Fork 679
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
[mediaqueries] Consider exposing "mobileness" as a media query #7696
Comments
Not terribly clear to me what this query is supposed to mean. There are quite a few characteristics typically associated with mobile devices already exposed through media queries. Presumably the request for one more means that what we have now is insufficient… but insufficient in what way? |
I'm not sure they're insufficient. It seems browsers already have somewhat different rendering for Still, the mobileness concept exists in implementations and in the CH spec. I can imagine a few possible scenarios:
|
We already had "mobile-ness" in the (now deprecated) media types. Media types had their own specific issues, but for detecting mobile devices specifically, the type just wasn't very coherent. There's no firm boundary between a phone and a tablet, or a tablet and a laptop (particularly those that can fold the screen back to switch into a tablet-like mode). Between size and pointer we capture most of the differences; anything missing which has a demonstrated use-case we're more than willing to entertain adding a new MQ for. |
What’s a mobile device anyway? Is it the same as a moving or movable device?
For several of those scenarios, user distraction and focus are relevant factors while designing user interfaces. They are different from whether direct interaction with a touchscreen is possible. They are also different from how big the screen is or what is its orientation and how far away it is from the user’s eyes. Several mobile devices do not even have a screen, but are audio-only (and hardly any of them consider CSS). |
I think people are getting a bit lost in the theorizing here... The fact of the matter is, browsers expose a single mobileness bit in their user agent string. People use this to build websites in various ways, including e.g. server rendering. @zcorpan suggests that maybe browsers also control some other things with this single bit. (Which I know to be true in some areas, although I don't know for sure about the cases he mentions, like select menu.) Maybe they shouldn't use this bit to style websites! In which case the CSSWG can decide not to expose it as a media query. Then people who really want it will just server-render But maybe such styling is a legitimate use case, and should be supported with a first-class media query! If user agents themselves use it for e.g. To recap, we're talking specifically about the existing mobileness bit that user agents definitely have and already expose through other means. We're not talking about relitigating the definition of mobileness. |
That would be exactly my point. The current idea of mobileness is severely flawed and should not be exposed as a MQ verbatim. |
Right, we deprecated the media type and didn't reproduce it in a MQ (instead reproducing the axises of variation people actually want to respond to) precisely because it's an incoherent concept and never what you actually want. There are many axises of variation you can possibly care about (screen size, existence of a pointer or hover capability, etc) and while there is a meaningful clustering of those values into something we call "phones", there's more than enough overlap in device capabilities that addressing that cluster is usually doing your users a disservice. Small screen layouts are usually desirable when a desktop user has a narrow window at the side of the screen, hover-less layouts are useful when webpages are displayed on TVs despite having desktop-ish sizes, etc. If browsers have more differences than what are currently covered by appropriate MQs, and there's a reasonable use-case for exposing those differences to authors, we can add MQs to cover them. But I don't think the logic behind deprecating the media type is invalid. |
In Chromium, the The reason I raised this issue is that for the new @media screen and (max-width: 500px) {
... styling for "full screen" select ...
} I anticipate endless haggling over 500px or 499px or 501px or 682px. Having said that, and given that the desire is to switch to a "small screen friendly" layout when "the screen is too small", using actual screen size does make sense. I was just hoping to side-step the bikeshedding over the pixel value. I see the points above that mobileness is kind of funny. |
If possible, I think the mechanism we decide for I don't mind switching to a MQ instead of using mobileness, if that's deemed better and is sufficiently web compatible for |
The trouble with that is that the "native" picker for The difference for |
This can happen on desktop by shrinking the window, or even using an |
In working on this further for @media (pointer: coarse) and (max-width: 10cm) { The The above CSS is functional and achieves the use case. However, What would be great is something like: @media (pointer: coarse) and (screen-size: medium) { I said Is that something the CSSWG would be interested in thinking about? |
What if only one dimension of the screen is small, but the other is big? Also, I'm not convinced by the argument for not defining them. What will happen is that authors will rely on whatever Blink chooses, and Blink will be locked into that initial choice to avoid breaking sites. |
Yeah, that's a good question. Mostly people use the width as a proxy, but again here, this might be a great reason to let the UA define it? That device doesn't exist (or isn't common today) so it's impossible to get it 100% right without knowing how it's used. The alternative of hard-coding a specific width seems worse in this case, doesn't it?
I agree that would be a bad outcome. How do you propose we define it to avoid this problem? My hope was that by not defining it in terms of pixels, developers would use it more for the qualitative breakpoints, such as "more padding", or "add a backdrop". Perhaps browser devtools can randomize the breakpoint, so developers can't count on a width while developing? I'm open to suggestions. |
I tend to think the authors should define the boundaries themselves, like @custom-media --mobile (pointer: coarse) and (max-width: 10cm);
@media (--mobile) {
...
} |
This reminds me a bit of the classic ubiquitous computing device classes:
|
@mfreed7 do you want screen size or layout viewport size? Note that https://drafts.csswg.org/mediaqueries-4/#mf-deprecated (and CSSOM) allows UAs to not expose the screen size. Are coarse screen sizes (small/medium/large) OK to expose from a fingerprint perspective? |
I suppose layout viewport size is fine. Again the use case is small-screen mobile which typically doesn't have the ability to resize the viewport.
I would think much more fingerprinting information is available via |
See whatwg/html#8224 (comment)
Has this been considered?
The definition in the Client Hints spec seems a bit vague to me, but I believe most browsers have an internal mobileness concept which affects rendering of some things, in particular
<select>
and<select multiple>
.Maybe browsers should do something else like key off of viewport size and
pointer
MQ?cc @mfreed7
The text was updated successfully, but these errors were encountered: