Re: Proposal: Form factor media queries

On Thu, Dec 8, 2011 at 12:56 PM, Brian <irishb@gmail.com> wrote:
> With all of the attention being given to responsive design approaches, I
> could not help but wonder what will happen in as little as a few years.
> Smartphones will likely have resolutions that will either rival or supersede
> present-day laptop resolutions, so our approach of detecting screen
> resolution and/or pixel density will be useless as a means to detect form
> factor. What we need in a media query is the ability to detect a true form
> factor, a "device-type" if you will, something along the lines of the
> "handheld" query of HTML4 lore that was abandoned after the iPhone was
> released and refused to implement it, to prevent a bad user experience.
>
> I imagine something akin to: <link rel="stylesheet" media="handheld, tablet"
> src="style-handheld-tablet.css">

There's already a "handheld" media type, and a "tablet" media type
would be appropriate next to it.

Unfortunately, these media types are fundamentally broken, as you
allude to.  The Media Queries specification currently requires media
types to be *exclusive* - a device is only allowed to match *one* of
them at a time.  Thus, no major phone has ever matched "handheld",
because the large number of sites that specified "screen" in their CSS
(usually to exclude the styles from "print") would simply break.  The
same thing stops anyone from matching "tv", and would do the same to
"tablet".

There are two solutions I see that could work for this:

(1) Fix MQ so that browsers are allowed to match both "screen" and
handheld/tv/projection/tablet at the same time.  If necessary, add a
new type that functions as an exclusive desktop-targetted typed, since
"screen" no longer functions as that.  Opera already fakes this
approach, by matching projection when in fullscreen *if and only if*
they detect a projection stylesheet; otherwise, it matches screen.  I
don't know what GoogleTV ended up doing, but they discussed the same
fakery with the tv type.

(2) Deprecate the handheld/tv/projection media types, and make a new
media query with those values instead, perhaps named "device-type".
If necessary, mint another value for typical desktop/laptop screens.

Now that Anne's no longer the editor of MQ, I suppose Florian is the
one to ask about this.  What say you, Florian?

~TJ

Received on Friday, 9 December 2011 16:29:01 UTC