What are the differences between link and @import?

hzc
Release: 2020-06-24 17:13:43
Original
3186 people have browsed it

The differences between link and @import are: 1. @import is a syntax rule provided by CSS and can only import style sheets. Link is a tag provided by HTML. It can not only load CSS files, but also define RSS, rel connection attributes, etc.; 2. @import is a syntax only available in CSS2.1.

What are the differences between link and @import?

#1. Difference in affiliation

@import is a syntax rule provided by CSS and only has the function of importing style sheets; link is provided by HTML Tags can not only load CSS files, but also define RSS, rel connection attributes, etc.

2. Difference in loading order

When the page is loaded, the CSS introduced by the link tag is loaded at the same time; the CSS introduced by @import will be loaded after the page is loaded.

3. Compatibility difference

@import is a syntax only available in CSS2.1, so it can only be recognized in IE5; the link tag is an HTML element and has no compatibility issues.

4. The difference in DOM controllability

You can operate DOM through JS and insert link tags to change the style; because the DOM method is based on documents, you cannot use @import to insert styles.

Recommended tutorial: "css tutorial"

The above is the detailed content of What are the differences between link and @import?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!