Summarize the differences between link and @import in loading CSS

Source: Internet
Author: User
There are two ways to load CSS: <link> @import

    • Way

       <link
       Rel= "stylesheet" href= "a.css"/> @import url ("B.css"); 
    • Contrast explanation

      • How to style: inline style, inline style, inline style, import style

      • Inline style > Import style

      • when @import with inline style <style></style>
      • In addition to the above, other times the order of style loading is referenced, the higher the priority of post-load. (It has been tested, can also be referenced here)
        Remember that when testing, you must test with the same element using the same selector, or the interference of the selector weight will occur. The

      • Link belongs to the XHTML tag, and @import is provided by CSS;
        Link tag in addition to the CSS can be loaded, but also do a lot of other things, @import can only load CSS.

      • Import is only recognized over IE5, and link is an XHTML tag with no compatibility issues;

      • When the
      • page is loaded, link is loaded at the same time, and the CSS referenced by @import waits until the page is loaded and then loaded;

      • About precedence

      • What you need to be aware of when using import: The rule must be declared first in the style sheet header. And then the semicolon is required, and if this semicolon is omitted, the external style sheet will not be imported correctly and an error message will be generated.

      Related recommendations

      1. Free CSS online video tutorial

      2. CSS Online manual

      3. php.cn (2)-css video tutorial

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.