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 trialAaron Rodriguez
2,232 PointsIs it ever okay to use internal styling? Would it be okay on single page websites?
I was looking around and exploring the code of different websites and found one in particular that wrote most of their CSS in the HTML document. Is that common?
5 Answers
kartik me
973 PointsFor a single static website its ok to use internal css but its recommend to use external css bcoz u have flexibility and maintainability over your documents
Emil Pesaxov
3,684 PointsHi, using inline styling is considered the worse of the 3 options. External CSS files is the best way to style as it seperates your HTML from CSS. It is best to keep each language seperated and linked as connection.
Even if your project is small and not something serious, it is considered a good practice to use external stylesheet. Good Luck!
Steven Parker
231,275 PointsNote that the question asks about "internal" and not "inline" styles.
Steven Parker
231,275 PointsSamuel's suggestion that "internal styles will override the styles in the css file" is not necessarily correct. Internal styles (in <style> tags) would be subject to cascade rules and would not override any external style sheets loaded later. That, and the reference to "scroll to the long html file to find the element" make it sound like he was talking about inline styles instead of internal styles.
"Best practice" would be using an external stylesheet for all CSS. But that said, I do occasionally step outside this guideline myself when the number of styles is very small and they pertain only to the one page I place them on. But this admission is not to be taken as a recommendation.
MEHDI ELAZZOUZI
1,204 PointsMy point of view
It is best to make it in a file that you may need to add other pages in the future
The arrangement of the first is good though you do not need it
JASMINE DAVIES
7,801 PointsHi, I wanted to mention that I think this system is useful for HTML emailers.
We often have requests to create emailers as a single HTML files. I think this way is useful for that, as it's not linked to an external CSS file, i.e. its all contained in one file.
SAMUEL LAWRENCE
Courses Plus Student 8,447 PointsSAMUEL LAWRENCE
Courses Plus Student 8,447 PointsIt is ok to do that, but not recommended. Internal styles have higher importance and if later you wish to make changes or add another page and you create an external css file, the internal styles will override the styles in the css file. It is ok to do internal styles, but every time you need to make changes you have to scroll to the long html file to find the element you want to change. Even if it's a single page but has a lot of content finding what you want to change can be time consuming. It will be much easier and manageable to have an external css file.