Re: [media-queries] chicken-egg problem with font-based lengths

On Sun, Aug 19, 2012 at 10:00 PM, Tab Atkins Jr. <jackalmage@gmail.com> wrote:
> On Sun, Aug 19, 2012 at 10:23 AM, Giuseppe Bilotta
> <giuseppe.bilotta@gmail.com> wrote:
>> the main question: which values of font-based length (em, ex) are used
>> when evaluating length-based media queries that make use of them?
>> For example, say that I have a media query of the sort: @media
>> (min-width: 66em).
>
> Both 'em' and 'rem' units in media queries are based off of the
> *user's default font size*, not the font size of the root element.
> This is not something that can be changed by CSS, and it's known
> before the page ever loads.
>
> Most of the time, 1em will thus equal 16px (the most common default
> font size).  However, users may adjust their default up or down (most
> commonly up, to help make text more readable).

Thank you very much. After you mentioned this I finally found the
relevant text @ http://www.w3.org/TR/css3-mediaqueries/#units

"Relative units in media queries are based on the initial value, which
means that units are never based on results of declarations. For
example, in HTML, the ‘em’ unit is relative to the initial value of
‘font-size’."

(and also a note about this in Example 25).

While this surely greatly simplifies the implementation, it does
become bothersome in my case, because it means I cannot _reliably_
size the #content container when selecting a font different from the
user's default one. I guess I'll have to think about some different
approach to achieve a wrapping container.

-- 
Giuseppe "Oblomov" Bilotta

Received on Monday, 20 August 2012 02:01:21 UTC