W3C home > Mailing lists > Public > www-style@w3.org > January 2012

Re: [Bulk] Re: @import -- allow at any place in stylesheet.

From: François REMY <fremycompany_pub@yahoo.fr>
Date: Tue, 17 Jan 2012 17:53:54 +0100
Message-ID: <0738D444EE2546CFBFCE965CB4D7BA70@FREMYD2>
To: "Tab Atkins Jr." <jackalmage@gmail.com>, "Marat Tanalin | tanalin.com" <mtanalin@yandex.ru>
Cc: <www-style@w3.org>
As a side note, it's also an optimization. As soon as the CSS file is 
received, the browser can know if there will be additionnal files to 
download. The more at the top the url is, the more quickly the new download 
can start. Also, the browser know at the first non-@import rule that he 
don't need to download new (css) files. This can help to make decisions for 
questions like "do I need to keep that TCP connection open?".

Sometimes, enforcing rules is better than try to get people writing good 
code. It may be the case here.


-----Message d'origine----- 
From: Tab Atkins Jr.
Sent: Tuesday, January 17, 2012 5:14 PM
To: Marat Tanalin | tanalin.com
Cc: www-style@w3.org
Subject: [Bulk] Re: @import -- allow at any place in stylesheet.

On Mon, Jan 16, 2012 at 7:36 AM, Marat Tanalin | tanalin.com
<mtanalin@yandex.ru> wrote:
> Hello. It makes sense to allow @import at any place in CSS stylesheet.
> For example, if we have:
>    .rule-before-example {...}
>    .example {...}
>    .rule-after-example {...}
> We could have same expressed with @import:
>    @import "before-example.css";
>    .example {...}
>    @import "after-example.css";
> where "after-example.css" contains:
>    .rule-after-example {...}
> (Real-world imported stylesheets are, of course, much larger.)
> So why should @import be disallowed here for importing 
> "after-example.css"? This just makes development less usable/flexible.

What does this help with?

The restriction that @import has to appear at the top of a file is
meant, I believe, to make it easier to understand that other files are
being imported.  A lone @import in the middle of a file is easy to
accidentally skip over for a human.

Note that if you really want to interleave some imported code, you can
do so by just using *more* imports, like:

---top of file---
@import "before-example.css";
@import "example.css";
@import "after-example.css";

Received on Tuesday, 17 January 2012 16:54:21 UTC

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