[Prev][Next][Index][Thread]

Re: @page and @media vs. @import



On Aug 4, 11:09pm, Liam Quinn wrote:

> I'm not sure how CSS1's @import relates to @page and @media

They are all examples of at-rules.

> with regard to
> the requirement that "all '@import' statements must occur at the start of
> a style sheet, before any declarations." [2]  @page and @media are not
> declarations, but they contain declarations.  Must @import statements
> therefore occur before any @page and @media statements?

Yes.

> As well, can @import be used within @media?  Could you have a style sheet
> like the following:
>
> @media print {
>   @import url(print.css);
>   BODY { font-family: Times, serif }
> }
> @media screen {
>   @import url(screen.css);
>   BODY { font-family: Verdana, sans-serif }
> }
>
I suspect not; it look attractive but the rule about @import is needed
to define the cascading mechanism. Changing it might be possible, given
a clear need and analysis of backwards-compatibility impact.

> As a side issue:  Is the syntax @import "screen.css"; (i.e., without the
> url() notation) valid?  The CSS1 grammar [3] gives [STRING|URL] under
> 'import' and one example [4] in the spec offers @import "subs.css";, but
> elsewhere only @import url(foo.css); is used.  If both are valid, why?

Backwards compatibility. STRING is deprecated. Don't use it. Warn
against it when found in a validator :)

> Finally, are there any requirements on where @media can occur in a style
> sheet?  Could you use
>
> BODY { font-family: Verdana, sans-serif }
> @media screen {
>   BODY { background: aqua; color: black }
> }
> H1 { text-align: center }
> @media screen {
>   H1 { text-decoration: blink !important } /* hehe */
> }

I don't see any restrictions (apart from being after any @import),
the examples

-- 
Chris Lilley, W3C                          [ http://www.w3.org/ ]
Graphics and Fonts Guy            The World Wide Web Consortium
http://www.w3.org/people/chris/              INRIA,  Projet W3C
chris@w3.org                       2004 Rt des Lucioles / BP 93
+33 (0)4 93 65 79 87       06902 Sophia Antipolis Cedex, France


References: