还是只是个人喜好问题?我的意思是,使用这两种方法有特定的好处吗?
<link href="main.css" rel="stylesheet" type="text/css">
对比
<style type="text/css">
@import url('main.css');
</style>
最佳答案
根据雅虎的 Best Practices for Speeding Up Your Web Site , 始终使用 <link>
而不是 @import
.更多详细信息,请参阅 this blog post .
In IE (tested on 6, 7, and 8),
@import
causes the stylesheets to be downloaded sequentially. Downloading resources in parallel is key to a faster page. This behavior in IE causes the page to take a longer time to finish.
使用 <link>
允许浏览器打开额外的连接,从而减少加载时间。
关于html - 使用 link 标签或 style 标签导入 CSS 哪个更好?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1495791/