@import
in CSS
Used to import style rules
from other style sheets .Used when the one style sheet requires the
style
rules of another style sheet.
Syntax :
- import url
- import url list-of-media-queries
eg:-
@import 'style.css'
@import url('land.css') screen
and (orientation:landscape);
The @import rules must precedes all other rules except @charset rules.In the absence
of media query the import is unconditional.If there media
queries exists then we need to specify each media queries in the
@import statement.
It can be prevented style sheets from download concurrently.
ie, if style sheetA
contains the text
@import url(“stylesheetb.css”)
then the download of second style sheet may not start until the first style sheet has been
downloaded.when compared with <link> it's a slower process
,because when we specify the css styles sheets in link it will executed in parallel(every process starts at same time).but which executed in serial when we specifies the rule using @import.
So
it's not a good idea to use the @import when we look from the page
speed standpoint .If
you need a style sheet that depends
on another one, use @import. Do the optimisation in a separate
step.If
you have one style sheet that depends
on
another, the most logical thing to do is to put them in two separate
files and use @import. That
will make the most logical sense to the next person who looks at the
code.

No comments:
Post a Comment