...

View Full Version : @import... any disadvantages?



rmedek
02-16-2005, 06:55 PM
I asked this question semi-off-topic in another thread and it sort of got lost in the shuffle. I did some research and couldn't find anything. The question: Are there any disadvantages to using @import methods of linking to CSS? Besides the obvious (legacy browsers don't understand it)...

Graft-Creative
02-16-2005, 07:18 PM
I think Opera 7.5, in small screen rendering mode, ignores any stylesheets imported in this way. I'm not too well up on this, but I think the main problem may be that some non-conventional, but modern, user agents dont get @import.

Kind Regards,

Gary

liorean
02-16-2005, 08:00 PM
Hmm, haven't tried Opera in small screen rending mode, but I doubt that it's a problem. More likely the problem is media type related..

One problem with @import is that iew only allows three levels of importation. Not that I think there's especially many that use more than one level in any case...

mcdougals4all
02-16-2005, 08:10 PM
I think one advantage to referencing the .css thru the <link> element is that you can take advantage of the rel and title attributes.

http://www.w3.org/TR/REC-html40/present/styles.html#h-14.3.2

Specify that the style sheet is persistent, preferred, or alternate:
To make a style sheet persistent, set the rel attribute to "stylesheet" and don't set the title attribute.
To make a style sheet preferred, set the rel attribute to "stylesheet" and name the style sheet with the title attribute.
To specify an alternate style sheet, set the rel attribute to "alternate stylesheet" and name the style sheet with the title attribute.


http://www.w3.org/TR/REC-html40/struct/links.html#linksandss

When the LINK element links an external style sheet to a document, the type attribute specifies the style sheet language and the media attribute specifies the intended rendering medium or media. User agents may save time by retrieving from the network only those style sheets that apply to the current device.

mindlessLemming
02-16-2005, 10:47 PM
If you wanted opera to use your stylesheet in SSR mode, you would declare it like so:


<style type="text/css" media="screen,handheld">
@import...
</style>


The main problem with @import is that it suffers from flash of unstyled content (http://www.bluerobot.com/web/css/fouc.asp).

rmedek
02-17-2005, 05:33 PM
Thanks for the tips guys... good point about the "rel" and "title" attributes.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum