The difference between CSS Import and link _ experience Exchange

Source: Internet
Author: User
See most of the pages in some websites are written like this



And many websites use the link



And like Google Baidu 163 and other sites they are directly written on the page

Of course, the advantage of using link links and import imports is easy to maintain, but when the network speed is slow, there will be load interruptions, resulting in page typographical errors

They both have the same effect.

The only difference is that the service object is not the same

@import for CSS Services

Link is the service for the current page

The classic Netizen said @import would give priority to implementation.

The difference between link and @import in external reference CSS

These two days have just finished the XHTML loading CSS in several ways, in which the external reference CSS is divided into two ways link and @import.

Essentially, both of these approaches are meant to load CSS files, but there are subtle differences.

Difference 1: The difference between ancestors. Link is an XHTML tag, and @import is completely a way to provide CSS.
In addition to the link tag can be loaded CSS, but also can do a lot of other things, such as the definition of RSS, the definition of REL connection properties, @import can only load CSS.

Difference 2: The difference in the loading order. When a page is loaded (when viewed by the browser), the CSS referenced by the link is loaded at the same time, and the CSS referenced by @import waits until the page has been downloaded and loaded. So sometimes browsing @import loading CSS page when there is no style (that is flashing), the speed of the slow time is quite obvious (dream of the way to load CSS is to use the @import, I download while browsing the dream of the Web page, the above problems will occur).

Difference 3: Differences in compatibility. Because @import is CSS2.1 proposed by the old browser does not support, @import only in IE5 above the ability to identify, and link tag does not have this problem.

Difference 4: The difference between using the DOM to control the style. When using JavaScript to control the DOM to change styles, you can only use the link tag, because @import is not controlled by the DOM.

Roughly the difference (if there's any difference, I'll add it again), the rest is the same, from the above analysis, it is better to use the link tag.
  • Related Article

    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.