Link versus import

admin

Administrator
Staff member
Is there any difference in speed or effectiveness between these two ways of using an external stylesheet?<style type="text/css"><!--@import"/style.css";--></style><link href=http://www.webdeveloper.com/forum/archive/index.php/"/style.css" rel="stylesheet" type="text/css">No speed difference, some filtering effect because old browsers don't understand @import so you can hide the "spiffy" stuff from them using that.If you want to do stylesheet switching, <link> is better.

I sometimes <link> a CSS file that @import's other CSS files to get the benefits of both.Ray: What type of stuff would you want to hide from older browsers? I can only imagine what you'd want to hide from newer browsers (i.e. obselete hacks).I hope you don't mind my answering for you Ray.

In this case, he is referring to IE4 and NS4.

They don't fully support @import, so by using it you can hide CSS code from them.

<!-- m --><a class="postlink" href="http://www.dithered.com/css_filters/css_only/index.php">http://www.dithered.com/css_filters/css_only/index.php</a><!-- m -->

If you saw how IE4 and NS4 completely mangled a tableless layout before the CSS was hidden from them, you would understand why we do this.I hope you don't mind my answering for you Ray.Not at all.
 
Back
Top