...

View Full Version : Importing a CSS document



[Unknown]
02-04-2007, 07:15 PM
Hello,

Are there any disadvantages to using:



@import url(document.css);


Also, what is the most compadiable way to import a CSS document?

_Aerospace_Eng_
02-04-2007, 07:35 PM
Not really any disadvantages but not really any advantages either at least not now. The use of @import for stylesheets is to hide it from older browsers like NS4 which is probably not being used anymore. Read this for more information.
http://css-discuss.incutio.com/?page=ImportHack

Arbitrator
02-05-2007, 04:22 AM
; 530611"]Are there any disadvantages to using:


@import url(document.css);

Also, what is the most compadiable way to import a CSS document?I think compatibility issues are the main disadvantages.

For example, Internet Explorer doesnít recognize @import url("document.css") all, which would make the style sheet accessible to all media; I believe that Internet Explorer does recognize the other media types when specified in this manner though: for example, @import url("document.css") print works. If youíre using JavaScript to dynamically disable, enable, insert, or remove style sheets, it may also be more difficult to do this with an import at‐rule because of lack of support for parts of the DOM2 Style Module (http://www.webdevout.net/browser-support-dom#dom2style) by various browsers.

Compatibility issues aside, I donít think that you can specify alternate style sheets or style sheet titles when specifying style sheets this way either.

If you donít need to do those things though, I see no problem with using it. I like keeping all CSS information in one specific place in a document: the style element. The following seems more organized than the code below it:


<style type="text/css">
@import url("master.css");
@import url("special");
@import url("iecompatible.css");
@import url("print.css") print;
/* styles specific to only this page */
*.old { color: silver; }
</style>


<link rel="stylesheet" type="text/css" href="master.css">
<link rel="stylesheet" type="text/css" href="special.css">
<link rel="stylesheet" type="text/css" href="iecompatible.css">
<link rel="stylesheet" media="print" type="text/css" href="print.css">

<style type="text/css">
/* styles specific to only this page */
*.old { color: silver; }
</style>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum