What
is CSS (Cascading Style Sheets)?
SolveYourProblem.com Article Series: Web Site Design
When HTML started, people put all sorts of
things on their pages: there was a tag to say which font you
wanted your text to be in, a tag to say you wanted it to be
in the center of the page, and so on. Now, though, that way
of writing pages is out-of-date and very inefficient compared
to keeping content and style separate using CSS.
What is CSS?
CSS stands for Cascading
Style Sheets it is basically a
way of saying once what you want your pages to look like, instead
of having to repeat it in HTML all the way through 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, though, 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>
Now, instead of having to say again which font you're using
with every new paragraph, you've told the browser that you
want every paragraph you've got to be in Arial.
Headings and Lists
Thanks to CSS, you can make documents that are more 'semantically
correct' that is, they would make sense to a human reading
them, instead of having to be weighed down with lots of extra
presentation code. This has two great effects: it makes web
pages smaller (and so faster to download), and it makes them
simpler.
On a modern web page, the only things you should ever 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 be done as messily as they often are.
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
any good way of making individual words bold or italicized,
so you can still use 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 one.
In theory, at least, that still means that it should be perfectly
possible to create a clean looking web page using only six
tags: h, ul, li, b, i and img. And, yes, it is very possible
if you can stick to this attitude towards web pages, your
page will be extremely clean, quick to download and fast to
display. If you've ever sat and waited more than a few seconds
for a page to load, you'll know how important this is.
Custom Stylesheets
One more advantage of this approach is that it lets your users
view your website however they want to. There are a surprising
number of users out there who are elderly or just want some
consistency on the web, and they have their own CSS stylesheets
to add to pages to make text bigger, for example, or make the
layout simpler.
Once you've written your page cleanly, you can even offer
visitors a choice of stylesheets yourself you can write more
than one 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 one available for any visitors that prefer it.
#
# # # #
SolveYourProblem.com : 2007
> Home > Website Design Articles: Main Page
|