CSS For Clean Page Design
What is CSS?
CSS stands for Cascading Style Sheets -- it is a way of specifying once what you want your pages to look like, instead of having to repeat it in HTML throughout the document.
In old style HTML, for example, this kind of code was a relatively common sight:
<p><font face="Arial">Welcome to my website!</font></p> <p><font face="Arial">I hope you enjoy your visit.</font></p>
Now, you can remove the font tags altogether, and just have this:
<p>Welcome to my website!</p> <p>I hope you enjoy your visit.</p>
At the top of your website, you put a style tag, like this:
<style>p { font-family: Arial; }</style>
That tells the browser that you want every paragraph you've got to be in Arial, unless you specifically override it.
Headings and Lists
Thanks to CSS, you can make documents that are more 'semantically correct' -- that is, they make sense to a human reading them, instead of being weighed down with lots of extra presentation code. This has 2 great effects:
-
it makes web pages smaller (and so faster to download)
-
it makes them simpler to design.
On a modern web page, the only things you should need to include, apart from paragraphs of text, are headings and lists. After all, web pages are just text, graphics, and navigation put together in a particular order -- there's no reason for things to get messy.
You use headings for the title and subtitles of your page -- they're the HTML tags that begin with h. You might, for example, write <h1>website title</h1><h2>article title</h2>.
Lists, on the other hand, can be used for pretty much anything else that isn't paragraphs of text. Instead of just putting links one after the other to make a navigation bar, for example, you should put them in a list, using the ul and li tags. Not only is this easier for you to read and add to, but it's also more compatible with non-graphical browsers.
A typical list looks like this:
<ul><li>item 1</li><li>item 2</li></ul>
Bold, Italic, and Images
Of course, in practice, you'll need a few more tags. CSS lacks a good way of making individual words bold or italicised, so you still need your b and i tags. Images, of course, still need a tag of their own too, although you might consider putting your images in a list if you have more than 1.
In theory, that means it should be possible to create a clean looking web page using only 6 tags: h, ul, li, b, i and img. And, yes, it is very possible, too.
If you stick to this attitude towards web pages, your page will be extremely clean, quick to download, and fast to display.
Custom Stylesheets
One more advantage of this approach is that it lets your users view your website however they want to. There is an ever growing number of users who are elderly or with special needs.
Once you've written your page cleanly, you can even offer visitors a choice of stylesheets yourself by creating more than 1 and then offer an option to switch between them.
This makes redesigning your page much easier if you ever need to, since you can simply swap one set of CSS for another and even leave the old 1 available for any visitors that prefer it.
|