I recently came across a use of the @import rule on Coda.com. They're actually using to import the main style sheet for the site, specifically the format:
<style type="text/css" media="screen">
@import url(./coda.css);
</style>
Which will hide the rules from Netscape 3 and IE 3 and 4. Since a web development tools primary audience will be using modern browsers, what other reasons would there be to use this rather then a link?
None. Using a <link>
element also has the advantage of getting rid of the FOUC.
EDIT: Using @import
in another stylesheet (.css
file) can be used like an #include
in C, but there isn't any reason to use @import
in a <style>
block.
For Coda's site, I'd imagine they did that more out of force of habit rather than any pressing technical need.
@import
statements inside of actual CSS files (not in a <style>
element in HTML) serve many purposes, such as making it easy to swap in and out other CSS files. The Blueprint CSS framework does this to let you easily remove certain portions of the framework such as the typography stuff or the grid stuff.
Of course, in a production environment, using a bunch of @import
statements is frowned down upon because it increases the number of files a web browser has to pull down.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With