CSS Unused CSS Stages Media Queries Media Features and Media Types

Dean Onizuka
Dean Onizuka
4,753 Points

purpose of @import and css style sheet linking of media queries

is there any instance where we would use the @import function for media queries that were shown in this video? or linking them in the html file via stylesheet like tags?

seems like the media queries work just fine without going to those lengths or am i missing something here?

2 Answers

Jacob Herper
Jacob Herper
85,770 Points

You can import CSS files into other CSS files to contain a clear structure. However most of the time you would rather include multiple CSS files through your HTML file, as @import might prevent stylesheets from being downloaded concurrently and slows down your page loading time. So the html link element is a better choice.

Also, older browsers don't support @import. So, in a roundabout way, you can use @import to "hide" styles from these older browsers (@import doesn't work for them, so they ignore the imported file).

But as Jacob said, I think it's best to go ahead and <link> the style sheet within the HTML.