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 trial
Torger Angeltveit
11,228 PointsDoes CSS inside a HTML document make the site load slower?
Is there a like a rule that i should always keep CSS and HTML seperated?
When I only want to make small design changes I like to just put some simple css inside the html tag. Does this make the page load slower then it would if i kept it in the css document? or is it okay to do it this way?
3 Answers
bleedcmyk
5,945 PointsNo. Its probably marginally faster on the first load, because the browser doesnt have to wait to load a second url. In general though it just makes your html messier for no real practical advantage and a few disadvantages.
For a website that gets a lot of traffic, it can be advantageous to have your styling in a CSS file because it gets cached. This means that it both loads faster the second time a person views that page or any other page using the same .css file, it also cuts down on bandwidth usage.
Torger Angeltveit
11,228 PointsThank you for answer!
I always separate huge CSS code.
But if i only wanted to change the color on a small p tag in html wouldn't it be great to do it like this
<p style="color:red;"></p>
``` instead of putting it in a separated CSS folder to keep the css cleaner and shorter?
bleedcmyk
5,945 PointsNot that big of a problem overall, but it can make it more difficult for another person to edit your CSS because they have to check for styling in two different places. I'd say its fine for personal projects, but try and limit it for client work etc.
Torger Angeltveit
11,228 PointsOk, thanks ;)