Skip navigation ]

Why separate style from content

Thursday, October 19, 2006

...And what does this even mean?

Imagine this scenario - you have just started working for a company, and have basic HTML knowledge. In their infinite wisdom, management have decided this qualifies you to make sitewide changes on the corporate site. A quick look at the first page of code shows 'tag soup' - hundreds of nested tags that have no resemblance to anything that you can make heads or tails of. [font] and [b] tags are littered around, and each separate element of the site seems to have its own personalised bit of styling. Tags should be in angular brackets, but are not in this example so they print properly in Blogger.

Now imagine the same scenario, but the code is well laid out and everthing has a class or ID that is controlled by a master stylesheet. Now to make changes, all you do is change the one sheet and the site changes. In the previous example, to make sitewide changes, you would need to edit every single line of code.

Which scenario would you prefer?

The second example shows one very good reason to try and separate the style from the content. In practice, this means laying out your basic HTML document (the framework) and then putting all tags which control the appearance e.g. width and font, into a separate stylesheet.

A more detailed explanation can be found here - http://www.tutorialtastic.co.uk/page/separating_style_from_content and here - http://phrogz.net/CSS/HowToDevelopWithCSS.html

If you have no idea where to begin with CSS, have a look at W3Schools, Tizag and the excellent free courses at WestCiv.

Labels:

Signed by Emma

Get paid to review my blog post

Subscribe to RSS feed Subscribe | By e-mail

Links

You can book hotels in Val d’Isere online for free cheap.
nummular excema treatment