Why use CSS?

So, why do people use CSS regularly to create websites? Why are they used around the globe in a huge majority of sites that are live on the internet. This site uses it, the BBC use it, everyone uses it. So, why?

The solution is simple. Picture this code:
HTML:
<font color=”#FF0000″>Hello</font>
<font color=”#FF0000″>My name is Jack and I like making websites.</font>
<font color=”#FF0000″>This is an example of bad coding.</font>
<font color=”#FF0000″>Now lets have a look at a better way</font>

Ok, what is wrong with that? The only thing is that you could place all the text into 1 <font> tag. So, apart from that nothing wrong.

Now, imagine that you are designing a website for a client who wants 20 pages, all with red text. Then, once you make those pages, the client comes back and decides that he/she would prefer blue. Now, who would want to open 20 pages one by one and replace all #FF0000 with blue? Not me personally. Now imagine this - instead of <font>, you have this:
HTML
<p class=”text”>Hello
My name is Jack and I like making websites
This code is nice!
Very nice!
</p>

And the css:
p {
color: #FF0000;
}

 And then all your HTML pages are linked to that stylesheet. Now, to change the colour, you edit just one line:
color: #0000CC;

Done, finished, finito. Which method would you prefer to use?

Leave a Reply