www.webdeveloper.com
Results 1 to 6 of 6

Thread: Link versus import

  1. #1
    Join Date
    Jun 2004
    Location
    England
    Posts
    2,972

    Link versus import

    Is there any difference in speed or effectiveness between these two ways of using an external stylesheet?
    Code:
    <style type="text/css"><!--@import"/style.css";--></style>
    Code:
    <link href="/style.css" rel="stylesheet" type="text/css">
    Disclaimer. (1) Whilst I will help you sometimes, if I feel like it, and my advice in relation to your actual question will be of good quality: my posts are to be taken with a pinch of salt. I will be sarcastic, deploy irony and include obscure cultural references for my own amusement without warning.
    (2) You will gain nothing from complaining, and if you try to argue with me then you will not win. No matter how noble your battle seems, I am still better than you, don't be an hero.

  2. #2
    Join Date
    Nov 2003
    Location
    Jerryville, Tejas
    Posts
    11,715
    No speed difference, some filtering effect because old browsers don't understand @import so you can hide the "spiffy" stuff from them using that.
    "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." Brian W. Kernighan

  3. #3
    Join Date
    Jul 2005
    Location
    USA
    Posts
    3,910
    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.

  4. #4
    Join Date
    Jun 2004
    Location
    England
    Posts
    2,972
    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).
    Disclaimer. (1) Whilst I will help you sometimes, if I feel like it, and my advice in relation to your actual question will be of good quality: my posts are to be taken with a pinch of salt. I will be sarcastic, deploy irony and include obscure cultural references for my own amusement without warning.
    (2) You will gain nothing from complaining, and if you try to argue with me then you will not win. No matter how noble your battle seems, I am still better than you, don't be an hero.

  5. #5
    Join Date
    Jul 2005
    Location
    USA
    Posts
    3,910
    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.

    http://www.dithered.com/css_filters/css_only/index.php

    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.

  6. #6
    Join Date
    Nov 2003
    Location
    Jerryville, Tejas
    Posts
    11,715
    I hope you don't mind my answering for you Ray.
    Not at all.
    "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." Brian W. Kernighan

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles