The difference between @import and link style calls in CSS

Source: Internet
Author: User

Link
Link is to connect the external CSS with the Web page.

@import
The difference between the import text and link is that it can introduce several other CSS files into a CSS file.

Why use @import
Most people who use the @import approach are because the old browsers do not support the @import approach, which means we can use @import to introduce CSS styles that allow only modern browsers to parse.
Another major reason is when your Web page needs to introduce several external CSS files. You can use link to introduce a CSS, and then introduce several other CSS files in this CSS file in @import. This looks easier to manage.

Why use link
One of the main reasons to use link mode is that you can allow users to switch CSS styles. Modern browsers such as Firefox,opera,safari support the rel= "Alternate stylesheet" attribute (you can choose a different style on the browser), Of course, you can also use JavaScript to enable IE to support user replacement styles.

@import little problem.
If your page head tag inside is very simple, only the @import attribute, when the user browsing speed is slow, he will see a no style style of the page, and then as the CSS file is downloaded to complete before you can see the style. To avoid such problems, You need to make sure that there is at least one script or link tag in the head.
04-11 Update: @import will make the CSS overall load time longer. And in IE it will cause the file download order to be changed, for example, the script file placed behind the @import will be downloaded before CSS.

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.