This forum is now read-only. Please use our new forums at discuss.codecademy.com.

CSS: An Overview Forum

View Course » View Exercise

154 points
F99aa4409fd2942fd32eb3b09383282c?s=140&d=retro
Submitted by
Chimone
about 4 years ago

Why use CSS and not just the html code we used before

why do you use css sheet when before we were just putting that code directly in with the html stuff, like why do you choose one way over the other?


4 votes

permalink

Inline styling (<p style="color: green;"></p>) can bloat out your code and are a nightmare to update if you have a lot of them.

External stylesheets (stylesheet.css) allow you to completely separate your CSS from your HTML everything is stored within a single file and once changed/updated, the changes are reflected on all other pages that reference the stylesheet.

This makes it easier to maintain larger websites and helps load pages quicker once the main CSS file has been cached and as a result bandwidth goes down.

effectively, you’re able to change the entire look and feel of a website through a single file.

The internal stylesheet (<style></style>) is placed within a page’s head tag and is intended to only modify the style of the page that includes it.

It's basically the mid point between the external and the inline styles. Like the inline the internal stylesheet is good when you need to make changes to a single document. Another good time to use this is when you only have to create one standalone page.There's no point in making a new css file for one page.

Hope that helps

276 points
513e1daed5a93991f9001468_977588295
Submitted by
martin smyth
about 4 years ago

2 Comments

F3f828442486663c9d8eafff9544b0a2?s=140&d=retro nathan buckley about 4 years ago

taaank you!

F3f828442486663c9d8eafff9544b0a2?s=140&d=retro nathan buckley about 4 years ago

taaank you!


0 votes

permalink

It's better to have a separate css file for maintenace. If you have 2 or 3 pages you can use inside css (with style), but if you work on a real website, let's say about 100 pages, how do you do that job in 1 hour?.
Answer adding a separate css file.

365 points
543fc82f631fe988640020d7_382532424
Submitted by
Tobias Páez
over 2 years ago