A brief introduction to the differences between CSS two introduced style files

Source: Internet
Author: User
This article gives you the content is about CSS two introduction style file of the difference between the simple introduction, there is a certain reference value, the need for a friend can refer to, I hope to help you.

CSS introduced style files have 2 kinds, are <link> tags and @import way, the following summarizes the difference between the 2!

The difference 1:<link> can reference not only the style file, but also other resources, but import can only introduce the style sheet file.


Difference 2: You can use JS to manipulate the DOM to insert <link> tags to change the style. For the @import approach, because the DOM method is document-based, you cannot use the JS operation @import to insert the style.


The CSS file introduced by the 3:<link> difference is loaded when the page loads, but the files introduced by @import wait until the page loads to load.


Difference 4: There is a slight compatibility problem with the @import (ie5+), but there is no compatibility problem with <link>.


Difference 5: @import can be used in Web pages, or in a CSS file, to introduce multiple CSS files into a CSS file, and link can only bring CSS files to the page pages. Note: When using @import in a CSS file, if there is a duplicate attribute defined, the value of the property @import introduced will be overwritten.

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.