- From: Bert Bos <bert@w3.org>
- Date: Tue, 10 Mar 2009 18:16:21 +0100
- To: www-style@w3.org
Maybe it's useful to write down why @import is the way it is, because that probably hasn't been written down anywhere yet. It may help to decide in the future what can come before an @import and what can't. The @import was designed using two principles (which in turn were meant to make it as easy as possible for users to remember how CSS worked): 1) The meaning of the rules in the imported style sheet doesn't depend on where the @import is called from. The caller only determines whether the style sheet is imported or not. Thus the caller (whether HTML or CSS) may attach conditions, such as Media Queries, but it may not change the meaning of any keyword or construct in the imported style. 2) Any rule in an imported style sheet can be overridden by a rule with the same specificity in the importing style sheet, but never the other way round. These rules are reminiscent of the import statements in Java or Modula, but different from the #include of C. (The #include of C has more "power" in theory, but the principle of least power applies here, and import is easier to understand.) However, to make sure that people who have the C model in their mind are not confused, we arranged the syntax so that there is no difference between import and include, namely by making the @import always the very first thing in the style sheet. So it doesn't matter if you think of @import as a macro, as in C, the eventual result of the style sheets happens to match that mental model as well. Bert -- Bert Bos ( W 3 C ) http://www.w3.org/ http://www.w3.org/people/bos W3C/ERCIM bert@w3.org 2004 Rt des Lucioles / BP 93 +33 (0)4 92 38 76 92 06902 Sophia Antipolis Cedex, France
Received on Tuesday, 10 March 2009 17:16:59 UTC