#1
  1. cosmos curator
    Devshed Novice (500 - 999 posts)

    Join Date
    Mar 2002
    Location
    Leeds, UK
    Posts
    678
    Rep Power
    14

    @import or <link>? - CSS


    I've been looking over CSS tutorials, articles, and other miscellaneous bumf, and I just happened to be wondering...

    What is the preferred or correct way to import style sheets: @import or <link>?

    I know that the @import rule under windows can have a strange side-effect of 'flashing' the unstyled content of the page before reflowing. So why use this, and not <link>?

    Is this something to do with standards ( not again, that terrible yet wonderous word), or just down to the coding preference of the developer?

    Comments and thoughts please ppl
    R.T.F.M - Its the only way to fly...

    "No matter what you do, or how good it is, someone will always ask for more features. Or to change the colour of something, then change their minds."

    Personal:
    experience// 8 Years Web Development
    technologies// Standards-compliant, valid, & accessible (x)HTML/CSS, XML/XSL/XPath/XQuery/XUpdate, (OOP) PHP/(My)SQL, eXist/Xindice/XMLDBs
    packages// Photoshop, Illustrator, Flash/Fireworks/Director
    environment// FC2, MySQL, Lighttpd, PHP5, Mojavi/Agavi
    site// //refactored.net/ (Coming soon...)
    quote// Programming is the eternal competition between programmers who try to make apps more and more idiot proof and the universe that makes dumber idiots. So far, the universe is winning...
  2. #2
  3. mod_dev_shed
    Devshed Supreme Being (6500+ posts)

    Join Date
    Sep 2002
    Location
    Atlanta, GA
    Posts
    14,817
    Rep Power
    1099
    I'm new to using @import too, but it's my understanding that @import is similar to an `include`. So let's say you default.css which only contains site wide fonts and default colors, then you have more specific stylesheets that would @import this default stylesheet, instead of repeating the style declaration or using multiple <link> statements.

    <link> is used within HTML, @import is used within the stylesheet itself.

    I'm sure someone will correct me if I understood all of this incorrectly.
    # Jeremy

    Explain your problem instead of asking how to do what you decided was the solution.
  4. #3
  5. |<.+#f@#+.&.|
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Mar 2002
    Location
    norway
    Posts
    3,009
    Rep Power
    1224
    i usually use @import

    just remember that netscape 4.x
    don't support @import.

    but you can use that to an advantage,
    use a simple style in the link for netscape,
    and an more advanced style in the @import
    http://www.dcjt.demon.co.uk/dc/web/2002/hidecss.html

    just remeber that ie has its problem too http://www.bluerobot.com/web/css/fouc.asp
  6. #4
  7. cosmos curator
    Devshed Novice (500 - 999 posts)

    Join Date
    Mar 2002
    Location
    Leeds, UK
    Posts
    678
    Rep Power
    14
    Thats what i mean, the "flash"ing of content before the style is applied. Surely it would be better to just use <link> to avoid this bug?
    R.T.F.M - Its the only way to fly...

    "No matter what you do, or how good it is, someone will always ask for more features. Or to change the colour of something, then change their minds."

    Personal:
    experience// 8 Years Web Development
    technologies// Standards-compliant, valid, & accessible (x)HTML/CSS, XML/XSL/XPath/XQuery/XUpdate, (OOP) PHP/(My)SQL, eXist/Xindice/XMLDBs
    packages// Photoshop, Illustrator, Flash/Fireworks/Director
    environment// FC2, MySQL, Lighttpd, PHP5, Mojavi/Agavi
    site// //refactored.net/ (Coming soon...)
    quote// Programming is the eternal competition between programmers who try to make apps more and more idiot proof and the universe that makes dumber idiots. So far, the universe is winning...

IMN logo majestic logo threadwatch logo seochat tools logo