Skip to content

[mediaqueries-5] @import motivating example doesn't work? #1513

@cvrebert

Description

@cvrebert

Spec: https://drafts.csswg.org/mediaqueries-5/#custom-mq

The intro paragraphs give as motivation for custom media queries:

the same media query may be used in multiple places, such as to qualify multiple @import statements.
[...] In this way, a media query used in multiple places can instead be assigned to a custom media query,

This makes it sound like we could write something like:

@custom-media --narrow-window (max-width: 30em);
@import url("mobile.css") (--narrow-window);
@import url("more-mobile.css") (--narrow-window);

However, that doesn't actually seem legal, per css-cascade (emphasis mine):

Any @import rules must precede all other at-rules and style rules in a style sheet (besides @charset, which must be the first thing in the style sheet if it exists), or else the @import rule is invalid.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions