Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Apr 2005
    Posts
    95
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Importing a CSS document

    Hello,

    Are there any disadvantages to using:

    Code:
    @import url(document.css);
    Also, what is the most compadiable way to import a CSS document?

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Not really any disadvantages but not really any advantages either at least not now. The use of @import for stylesheets is to hide it from older browsers like NS4 which is probably not being used anymore. Read this for more information.
    http://css-discuss.incutio.com/?page=ImportHack
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    Senior Coder Arbitrator's Avatar
    Join Date
    Mar 2006
    Location
    Splendora, Texas, United States of America
    Posts
    3,306
    Thanks
    29
    Thanked 276 Times in 270 Posts
    Quote Originally Posted by [Unknown] View Post
    Are there any disadvantages to using:

    Code:
    @import url(document.css);
    Also, what is the most compadiable way to import a CSS document?
    I think compatibility issues are the main disadvantages.

    For example, Internet Explorer doesn’t recognize @import url("document.css") all, which would make the style sheet accessible to all media; I believe that Internet Explorer does recognize the other media types when specified in this manner though: for example, @import url("document.css") print works. If you’re using JavaScript to dynamically disable, enable, insert, or remove style sheets, it may also be more difficult to do this with an import at‐rule because of lack of support for parts of the DOM2 Style Module by various browsers.

    Compatibility issues aside, I don’t think that you can specify alternate style sheets or style sheet titles when specifying style sheets this way either.

    If you don’t need to do those things though, I see no problem with using it. I like keeping all CSS information in one specific place in a document: the style element. The following seems more organized than the code below it:

    Code:
    <style type="text/css">
      @import url("master.css");
      @import url("special");
      @import url("iecompatible.css");
      @import url("print.css") print;
      /* styles specific to only this page */
      *.old { color: silver; }
    </style>
    Code:
    <link rel="stylesheet" type="text/css" href="master.css">
    <link rel="stylesheet" type="text/css" href="special.css">
    <link rel="stylesheet" type="text/css" href="iecompatible.css">
    <link rel="stylesheet" media="print" type="text/css" href="print.css">
    
    <style type="text/css">
      /* styles specific to only this page */
      *.old { color: silver; }
    </style>
    For every complex problem, there is an answer that is clear, simple, and wrong.


  •  

    Posting Permissions

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