CSS Level 2
The @import rule
W3C Recommendation

The following is an excerpt from the W3C Recommendation, CSS Level 2 Working Draft as presented in Rijk’s Panelizer, an educational resource panel available for the Opera Browser User Agent (as of Opera 8, and probably earlier as well). I have taken the liberty to paraphrase, and re-structure some of the original text (which i appropriated directly from the W3C Recommendation). Since the focus of this entry is the @import rule itself, i felt it was appropriate to show emphasis where originally there might have been none.

  • ‘@import’ is used in a cascading stylesheet, or in the <style> section of a Standard, compliant html document
  • The ‘@import’ rule allows users to import style rules from other style sheets.
  • Any @import rules must precede all other rules (except the @charset rule, if present).
  • The ‘@import’ keyword must be followed by the URI of the style sheet [which the author wishes] to include. the proper syntax for that URI reference is url(style-sheet-location)
  • A string is also allowed [to be used for the URI reference]; it will be interpreted as if it had url(…) around it.

NOTE: The following lines are equivalient in meaning [and function]. The two examples which follow effectively illustrate the @import rule both with and without the url(“source-stylesheet-url”) syntax.@import “mystyle.css”;
@import url(“mystyle.css”);So that user agents can avoid retrieving resources for unsupported media types, authors may specify media-dependent @import rules. These conditional imports specify comma-separated media types after the URI.The following rules illustrate how @import rules can be made media-dependent:@import url(“fineprint.css”) print;
@import url(“bluish.css”) projection, tv;In the absence of any media types, the import is unconditional. Specifying ‘all’ for the medium has the same effect.

Important NOTE: It is my understanding as of 28-April-2006 that no draft revisions may be officially cited from other documents (such as this), because their content may change, and therefore not accurately reflect the final text intended for publication and reference by the W3C. Considering this, i ask that anyone who reads this text please reference NOT the 2.1 draft, but the CSS 2 Recommendation as the official resource. I will change the citations as soon as possible. Thank you!
(citations updated 4.28.06 1:56pm EST)W3C: Cascading Style Sheets, Level 2
CSS2 Specification
W3C Recommendation 12-May-1998

Whatchu do

Leave a Reply

Your email address will not be published. Required fields are marked *