SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Evangelist N9ne's Avatar
    Join Date
    Aug 2002
    Location
    England
    Posts
    581
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    @import or <link> ?

    I was just wondering, which way is better/more compatible? I've always been using <link rel="stylesheet" href="style.css" media="all" /> in my head tags...would using <style type="text/css">@import('style.css');</style> be better, and why?

  2. #2
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,236
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by N9ne
    I was just wondering, which way is better/more compatible? I've always been using <link rel="stylesheet" href="style.css" media="all" /> in my head tags...would using <style type="text/css">@import('style.css');</style> be better, and why?
    Either one will do the same thing (hide styles from NN4). Netscape 4 only shows a stylesheet if the media attribute is left blank, or if the value is "screen". It won't load the sheet for any other media type (including "all"). However, using @import the way you did would hide the stylesheet from IE5/Mac because of the single quotes. Try this if you plan on using @import:
    Code:
    /*to hide from IE4/windows*/
    @import "styles.css";
    
    /*to let IE4/Windows and other browsers load your sheet*/
    @import url(styles.css);
    
    /*to keep IE4-6 on Windows from loading the sheet*/
    @import url(styles.css) screen;
    Hope this helps!

  3. #3
    SitePoint Evangelist N9ne's Avatar
    Join Date
    Aug 2002
    Location
    England
    Posts
    581
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So really I may aswell stick with using the link tag?

  4. #4
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,236
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by N9ne
    So really I may aswell stick with using the link tag?
    Yeah, it's not going to change much either way.

  5. #5
    SitePoint Addict naveed's Avatar
    Join Date
    Feb 2003
    Location
    Ottawa, Canada
    Posts
    230
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)


Bookmarks

Posting Permissions

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