Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAnsh ⠀
6,521 PointsHow import works? Does positioning matters?
I'm confused how it works!
I mean am confused in 'cascading' part of CSS. Does import css files override current css file (in which I am adding this import)?
Please explain!
1 Answer
Amrit Pandey
17,595 Pointscascading means that the new sets of styles will override the old sets of style if they are written bottom of the old styles. So if you made two files say main.css and main2.css and you import main2.css in main.css at the end of main.css codes then all the same sets of styles appearing will be added to main.css. Also if there are new styles they will override the old styles of the elements!
Ansh ⠀
6,521 PointsI know what cascading means! But is it also applies with import?
Amrit Pandey
17,595 Pointsbro best thing is to experiment. and I can say yes it does though I have not experimented. Checkout for yourself thats a good experience!!
Nick Wilson
5,060 PointsNick Wilson
5,060 PointsI'm not sure what you mean exactly but, importing you can import as many CSS files as you like for your pages. Nothing will be over written unless you have two conflicting classes in 2 separate files. You can always inspect a page in a browser and view it's classes (css) to see which class is firing first. The inspection mode will have what line (example: line 332 of the css file) is firing.