Link and @import two kinds of import CSS file differences.

Source: Internet
Author: User

1. The difference between ancestors. Link is an XHTML tag, and @import is completely a way to provide CSS. Besides the ability to load CSS, link tags can do a lot of things, such as defining the Rel connection properties, @import can only load CSS.

2. Differences in loading order. When a page is loaded, the CSS referenced by link is loaded at the same time, and the CSS referenced by @import waits until the page is loaded and loaded. So sometimes browsing @import loading CSS page when there is no style, more obvious when the network speed is slow.

3. Differences in compatibility. Because @import is css2.1 proposed by the old browser does not support, only IE5 above to identify, and link tag does not have compatibility issues.

4. Use the DOM to control the differences in 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.

5. @import can introduce another style sheet in the CSS, such as creating a main stylesheet and introducing other stylesheets into the main style sheet.

Link and @import two kinds of import CSS file differences.

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.