Website Design > Web design and coding tips

When to use CSS @import and when the link tag


I found out about the CSS @import declaration when I saw it used to import the main stylesheet of the page:

--- Code: ---<style type="text/css">
@import url("main.css");
--- End code ---

This raised the question of when should you use the link tag:

--- Code: ---<link rel="stylesheet" type="text/css" href="..." media="screen" />
--- End code ---
and when the @import technique.

After a quick search in Google (plenty of info on the subject) I found out that using @import from the HTML directly was used in the days of yore to apply different styles for different browsers. Now a days this use is kind of irrelevant.

@import's original purpose is to modularize CSS styles (a good article on the subject) and it is better to use it like that and not to import the main style sheet. For the main / master stylesheet of the page one should use the link tag.


[0] Message Index

Go to full version