Author Topic: When to use CSS @import and when the link tag  (Read 476781 times)

December 12, 2007, 11:47:43 AM
  • Administrator
  • Full Member
  • *****
  • Posts: 7
    • View Profile

I found out about the CSS @import declaration when I saw it used to import the main stylesheet of the page:
Code: [Select]
<style type="text/css">
@import url("main.css");

This raised the question of when should you use the link tag:
Code: [Select]
<link rel="stylesheet" type="text/css" href="..." media="screen" />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.