This forum is now read-only. Please use our new forums! Go to forums

0 points
Submitted by Chimone
about 11 years

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?

Answer 51357cf5bd57db5338000e35

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

points
Submitted by martin smyth
about 11 years

2 comments

nathan buckley about 11 years

taaank you!

nathan buckley about 11 years

taaank you!

Answer 544c2c2d80ff33cc85000172

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.

points
Submitted by Tobias Páez
over 9 years