import和link之间的区别

import和link之间的区别

本文介绍了CSS中的@import和link之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我正在学习一些CSS来调整我的项目模板。我来到这个问题,没有找到一个明确的答案在网上。在CSS中使用@import或链接是否有区别?I'm learning some CSS to tweak my project template. I come to this problem and didn't find a clear answer on the web. Is there a difference between using @import or link in CSS?使用@import<style type="text/css">@import url(Path To stylesheet.css)</style>使用链接<link rel="stylesheet" type="text/css" href="Path To stylesheet.css" />最好的办法是什么?为什么? 谢谢!What's the best way to do it? and why?Thanks!编辑:有一些想法 here推荐答案理论上, c $ c> @import 是包含样式表和< link> HTML机制的CSS机制。但是,浏览器处理方式不同,< link> 在性能方面具有明显的优势。In theory, the only difference between them is that @import is the CSS mechanism to include a style sheet and <link> the HTML mechanism. However, browsers handle them differently, giving <link> a clear advantage in terms of performance. Steve Souders撰写了一篇广泛的博客文章,比较了< link> 和 @import 他们)称为不要使用@import 。这个标题本身就是说话。Steve Souders wrote an extensive blog post comparing the impact of both <link> and @import (and all sorts of combinations of them) called "don’t use @import". That title pretty much speaks for itself.雅虎!也提到它是他们的表现最佳实践之一(由Steve Souders合着):选择< link> over @importYahoo! also mentions it as one of their performance best practices (co-authored by Steve Souders): Choose <link> over @import此外,使用 ; link> 标记允许您定义首选和替代样式表。你不能用 @import 来做。Also, using the <link> tag allows you to define "preferred" and alternate stylesheets. You can't do that with @import. 这篇关于CSS中的@import和link之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
09-02 08:42