What is the difference between the css @import and the html link?

12

I created a file containing css patterns that are used on my system. I would like to know what is the difference between calling css by link or @import like this:

/* ou dentro do codEventos.css */

@import "../padrao.css";
<link rel="stylesheet" href="padrao.css">
<link rel="stylesheet" href="codEventos.css">

What are the advantages / disadvantages?

Read on a link: dont-use-import that there is a big difference in performance, since link can load css in parallel by having more performance on @import , of course not all browsers that interpret this way.

    
asked by anonymous 03.07.2015 / 16:20

2 answers

8
  

In theory, the only difference between them is that @import is the mechanism   CSS to include a style sheet and <link> is the HTML engine   to do the same. However, each browser manipulates them in ways   different, giving <link> a clear advantage in terms of   performance.

     

Steve Sourders wrote an extensive article on his blog, comparing the   impact of both <link> and @import (and all possible combinations   between them) called "do not use @import" use @import "). O   title says it all.

     

Yahoo! also mentions it as one of his best   performance (co-authored with Steve Sourders): Choose <link> over   @import . ("Choose <link> instead of @import").

     

In addition, using the <link> tag allows you to set   preferred and alternative styles. You can not do this with   @import.

This is a full translation of the English answer to the same question, which can be found at link

    
07.07.2015 / 18:33
0

There is basically no difference, the link is the html method of calling a stylesheet, the @import of the css.

However, browsers interpret them in a different way, where the link has a performance advantage.

If you understand English, check out this answer: link

Embrace

    
03.07.2015 / 16:27