Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What's the difference between link and @ import in css?

2025-03-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article focuses on "what's the difference between link and @ import in css". Interested friends might as well take a look. The method introduced in this paper is simple, fast and practical. Let the editor take you to learn "what's the difference between link and @ import in css"!

1. The difference of subordinate relationship

@ import is a syntax rule provided by CSS, which only imports stylesheets.

Link is a tag provided by HTML, which can not only load CSS files, but also define RSS, rel connection properties, and so on.

2. The difference of 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 unique to CSS2.1, so it can only be recognized in IE5+

The link tag, as a HTML element, has no compatibility issues.

4. The difference of DOM controllability

You can change the style by manipulating DOM through JS and inserting link tags; because the DOM method is document-based, you cannot insert styles using @ import.

5. Weight difference. The style weight introduced by link is greater than that introduced by @ import.

At this point, I believe you have a better understanding of "what's the difference between link and @ import in css". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 214

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report