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 trialamyp
6,574 PointsWhat is the main benefit of including CSS in an external file?
What is the main benefit of including CSS in an external file?
1 Answer
Christian Andersson
8,712 PointsThe benefits and drawbacks would depend on the size of the project. If you're just doing a simple one-page site (e.g landing page) then there's probably not any real benefits.
However, most websites and web applications are quite large and separating the markup from the layout is always a good idea, because it makes the different aspects of the site more easily manageable.
Another benefit is that you can use the same css file for multiple html pages, simply by just importing it within each page. If you were to do in-line css or embedded css, you'd end up with bigger files and if there's a global style you'd want to change in the future, you'd have to open each file and change it one-by-one.
Really, you should virtually always use external css whenever possible, and only use embedded or in-line css when needed in an edge-case scenario.
The reasons are many, and the examples are endless. I suggest googling this question if you need more in-depth examples.