W3C home > Mailing lists > Public > www-style@w3.org > May 2013

Re: [mediaqueries] calc() and other syntax restrictions (was: Re: Validating media queries in Java)

From: Simon Sapin <simon.sapin@exyr.org>
Date: Sun, 05 May 2013 08:05:52 +0200
Message-ID: <5185F6C0.7010508@exyr.org>
To: fantasai <fantasai.lists@inkedblade.net>
CC: "Tab Atkins Jr." <jackalmage@gmail.com>, Bjoern Hoehrmann <derhoermi@gmx.net>, "gunther.pilz" <gunther.pilz@gmail.com>, www-style list <www-style@w3.org>
Le 02/05/2013 21:46, fantasai a écrit :
>> Gunther: Don't worry, whatever conclusions that that old thread may
>> have come to, calc() is definitely allowed in Media Queries, at least
>> per spec.  (calc() is allowed*everywhere*, because it's just a
>> fill-in for its resolved type.)
> I am not so sure about that, and if that's our intent I think it could
> definitely use some clarification.

I agree with Tab. Whether or not this was originally intended, calc() is 
allowed in Media Queries per spec.


> Whitespace, <integer>, <number> and other values used by this
> specification are the same as in other parts of CSS, normatively
> defined by CSS 2.1. [CSS21]


> The ‘calc()’ expression […] can be used wherever <length>,
> <frequency>, <angle>, <time>, <number>, or <integer> values are
> allowed.

For comparison, attr() is not allowed in MQs. css3-values:

> The attr() function is allowed as a component value in properties
> applied to an element or pseudo-element.

That said, I’m always in favor of clarification in specs. And calc() is 
indeed not very useful in MQs, since eg. the em unit is based on the 
initial font-size and not one from a stylesheet.

Oh, and while we’re on conclusions of that old thread, I think that 
micro-syntaxes like MQs and Selectors should definitely use an actual 
CSS parser, up to what Syntax 3 calls "component values". This takes 
care of escaping, block/paren nesting and error recovery rules.

And allowing multiple escaping styles is fine as long as they’re 
properly layered: the HTML parser resolves HTML escapes/entities, and 
the parsed attribute value (as in the DOM) is given to the CSS parser 
which in turn handles CSS escapes, etc.

This is all already the case: MQ3 refers to the CSS2 tokens and grammar.

Simon Sapin
Received on Sunday, 5 May 2013 06:06:17 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:08:29 UTC