Thread: Homework Help
View Single Post
Old 02-19-2006, 02:19 PM   #15
Jeysie
Diva of Death
 
Jeysie's Avatar
 
Join Date: Aug 2005
Location: Western Massachusetts
Posts: 1,402
Send a message via MSN to Jeysie
Default

Mmm. Well, the fact that he's having you do layout (making a "dark" border) without having told you about CSS first makes me a little dubious of the fellow.

But anyway, CSS stands for Cascading Style Sheets. Essentially the idea is to separate structure and layout. In the XHTML file itself you have things like paragraphs, headings, tables, lists, etc. saying what the content *is*. Meanwhile, in the CSS file you have things like margins, colors, borders, fonts, etc. saying what the content should *look like*.

For instance...

Instead of having, say:

<body bgcolor="light blue">
<p align="center" color="black">Hello, world!</p>
</body>

You'd have a CSS file that said:

body {background:light blue;}
p {text-align:center;color:black;}

Note: This essentially says "Every <body> has a light blue background, and every <p> has centered text and black text."

and an XHTML file linked to the CSS file that said:

<body>
<p>Hello, world!</p>
</body>

Note: By "link" I mean linked to in the database sense of two files "merging", not in the hyperlink sense of one document pointing to another.

What's the real difference, you ask? Well, if you're just doing one file, not much. However, when you have lots of different XHTML files, all referencing the same CSS file, it gets a lot cooler. You could have a second XHTML file that went:

<body>
<p>Hello world, yet again!</p>
<p>Whee, isn't this fun?</p>
</body>

and this second XHTML file would "automagically" have the same layout as the first, just by linking to the same CSS file as the first.

Even more better is if you ever decide to change the layout. Let's say you decided you really wanted the background pink, after all.

You could go into every single XHTML file and change

<body bgcolor="light blue">

to

<body bgcolor="pink">

or you could simply change one CSS file rule from

body {background:light blue;}

to

body {background:pink;}

and have *every* XHTML file linked to that CSS file change background color automatically.

There are other perks as well... you have can have several alternate CSS files for the same XHTML file that you can switch between - like, one "screen" layout and one "print" layout, for instance.

By this point you're probably feeling a migraine coming on, so I recommend reading through:

http://www.htmldog.com/guides/cssbeginner/

It offers a lot of good beginner tips. In fact, I recommend reading through that whole site: it'll give you a good grounding.

Peace & Luv, Liz

P. S. CSS files are also text-based files, so you can edit all this stuff in Notepad. A CSS file has .css as an extension: like layout.css or something.
__________________
Adventures in Roleplaying (Nov. 19):

"Maybe it's still in the Elemental Plane of Candy."
"Is the Elemental Plane of Candy anything like Willy Wonka's factory?"
"If it is, would that mean Oompa Loompas are Candy Elementals?"
"Actually, I'm thinking more like the Candyland board game. But, I like this idea better."
"I like the idea of Oompa Loompa Elementals."
Jeysie is offline