W3C home > Mailing lists > Public > www-style@w3.org > April 2015

Re: [css-variables][mediaqueries] Allow var() in media queries?

From: Cameron McCormack <cam@mcc.id.au>
Date: Sun, 5 Apr 2015 09:41:59 +1000
To: Glen Huang <curvedmark@gmail.com>
Cc: www-style list <www-style@w3.org>
Message-ID: <20150404234159.GE16374@wok.mcc.id.au>
Glen Huang:
> When you design the media query break points according to certain
> element dimensions, being able to use variables in media queries can
> be very helpful.

I agree it would be helpful, but a problem with this is that you can
easily set up rules inside the @media that change what the @media
condition evaluates to:

  :root {
    --page-width: 768px;

  @media (min-width: var(--page-width)) {
    :root {
      --page-width: 120px;

So far CSS has avoided adding any new situations like this (the existing
problem with :hover rules moving the element is one we are stuck with).

Cameron McCormack ≝ http://mcc.id.au/
Received on Saturday, 4 April 2015 23:42:28 UTC

This archive was generated by hypermail 2.4.0 : Monday, 23 January 2023 02:14:50 UTC