2

i came across two type of using external style sheet in one way

<link href="CSS/div1.css" rel="stylesheet" type="text/css" />
<link href="CSS/div2.css" rel="stylesheet" type="text/css" />
<link href="CSS/div3.css" rel="stylesheet" type="text/css" />

importing all the style sheet like this and the other one is using one stylesheet and importing other stylesheet within it

<link href="CSS/div1.css" rel="stylesheet" type="text/css" /> and inside this
@import url('../CSS/div2.css');
@import url('../CSS/div3.css');
.crazy
{
 display:block;
 background-color:Black;
 color:White;
}

i read somewhere that the second approach is better so i built a demo and checked that one in firebug in the first case it is taking 16ms and also downloaded less byte of data but in the second approach it takes 109ms and downloaded more bytes of data so iam confused which approach is better.

Mac
  • 5,683
  • 8
  • 33
  • 66
  • you can find similar question at http://stackoverflow.com/questions/1022695/difference-between-import-and-link-in-css – N30 Aug 16 '10 at 14:52

4 Answers4

2

the first one is the suggested one because it's fasters for the browser to render them More on Steve's site

wezzy
  • 5,678
  • 3
  • 29
  • 42
1

Go with the first! Your test results are pretty clear!

bimbom22
  • 4,413
  • 2
  • 28
  • 46
1

Historically, @import has been used because it wasn't support by older versions of IE and Netscape, making it easy to hide more advanced CSS from those browsers. Nowadays that isn't so much of an issue, and other techniques are recommended when you need to target specific browsers with CSS.

As for your tests, whilst there are technical reasons why the second approach would be 'slower', I'd argue a simple look at Firebug can hardly be used as empirical evidence.

roryf
  • 27,986
  • 15
  • 77
  • 101
0

I always go for the first as W3C shows

http://www.w3schools.com/css/css_howto.asp

Mauro
  • 1,983
  • 2
  • 24
  • 47
  • 5
    That is not an official W3C site and it's tutorials are known to promote bad practices and have security holes. I wouldn't recommend it's usage to anyone. – roryf Aug 16 '10 at 14:48