The purpose of CSS

They have: 222 posts

Joined: Sep 1999

Alright, so, the purpose of CSS is to seperate content from markup, right? But, if you still have to go through your content and and reference everything to the stylesheet...what's the point?

Why is this:

<link rel="stylesheet" type="text/css" href="stylesheet.css">

<p class="bold">
blah this text is bold
</p>
'

Better than:

<p><strong>
blah this text is bold
</strong></p>
'

He has: 1,016 posts

Joined: May 2002

I never use CSS just to make a piece of thext bold. I guess if you want all 's to be bold, then the CSS method is handy since you can by changing one line in one file, change the look of all content between your tags. You can for example use td{} or body{} to format all text in your tag or your tables. It is very handy once you get a hang of it.

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

Let's say that the only reason you use is to emphasise some text. How about if you decide to change the style of emphasis on (all X number of pages in) your site? Say, you want to highlight the text in red instead of strong. You could simply alter the central CSS code once. Smiling

This helps you keep a style guide for your site, which is very useful. Makes editing so much easier. You can even easily play around with different styles when designing pages because you only need to change the code once.

The Webmistress's picture

She has: 5,586 posts

Joined: Feb 2001

Plus without all the font tags etc on the page it will load quicker as well as being quicker to edit later.

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

Yes, and it also makes the code neater, because everything is in the one tag. You won't have problems with interchanging opening/closing tags and so on.

Eg:<font size="2" face="verdana" color="#ff0000"><b><i><u>blah</font></u></i></b>'That is easily avoided:<span class="blah">blah</span>'

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.