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 trialklobi tonner
95 Pointsmixin makes your file bigger
Why would you use mixin insted and not just do header::after, footer::before { CODE } ?
1 Answer
Max Weir
14,963 PointsWell a mixin lets you reuse the function over and over and doing the hard work for you, vs writing from scratch each time. Plus it's less scss to add and can eliminate potential errors.
Ryan Dainton
17,164 PointsRyan Dainton
17,164 PointsYou could just do; header::after, footer::before { CODE }, as you suggested if that is the only time you are going to use that piece of code. However, as part of a larger project, you might want to use that code several times in different places, so a mixin would save you writing it out multiple times, keeping your code DRY (Don't Repeat Yourself).
The size of your SCSS files is not very important as the code is compiled into a CSS file. Anyway, if you are using mixins properly, to avoid repeating yourself unnecessarily, it should always keep your SCSS files smaller.