What's the best method to include CSS in page and why?
for eg.:
<style type="text/css">
@import "style.css" screen, tv;
@import "print.css" print;
@import "iphone.css" iphone;
</style>
or
<LINK rel="stylesheet" media="screen" href="style.css" type="text/css" />
<LINK rel="stylesheet" media="print" href="print.css" type="text/css" />
<LINK rel="stylesheet" media="iphone" href="iphone.css" type="text/css" />
From what i know @import
doesn't work in ancient browsers, this might be a advantage because these browsers will only show text instead of a unreadable CSS mess (when using link).
The media attribute specifies what media/device the target resource is optimized for. This attribute is mostly used with CSS style sheets to specify different styles for different media types.
Definition and Usage The required rel attribute specifies the relationship between the current document and the linked document/resource.
It has been discussed many times, you can read more here:
http://www.stevesouders.com/blog/2009/04/09/dont-use-import/
Difference between @import and link in CSS
http://webdesign.about.com/od/beginningcss/f/css_import_link.htm
to mention some...
Personally I never use @import as for the performance impact.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With