Alex Rivera | Logout

Is it better to use the link tag or the style tag to import CSS?

Asked 2009-09-30T02:03:15.223
23

Or is it just a personal preference thing? What I'm getting at is, is there a specific benefit to using either method?

<link href="main.css" rel="stylesheet" type="text/css">

versus

<style type="text/css">
@import url('main.css');
</style>
Edit
Report

1 Answer

23

According to Yahoo's Best Practices for Speeding Up Your Web Site, always use <link> instead of @import. More detailed information is available in 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.

Using <link> allows the browser to open additional connections, thereby decreasing load times.

answered 2009-09-30T02:06:35.273

Your Answer