CSS and DIV control

They have: 42 posts

Joined: Oct 2006

I've just begun using simple CSS on 3 of the web sites I maint.
I'm sort a newbie using them, so I probably should view tuts before
I ask.. but if any of you would indulge me I'll ask anyway Wink ...

Why do the div ids that I create, reside in the html page as well as
in the css file that I call out in the begining of the page?......i.e. I call out this line:

....right after the tag line

But further down in the page the , middle, footer, etc.
are also put there when I edit the html in Dreamweaver MX 04.

I tried seeing if the page would still work if I removed either, and
in each case, it failed to work.
I've noticed that while editing in Dreamweaver, I must include independent files during upload, i.e. the CSS, so that the html updates properly... Why?

Am I misunderstanding the function of the CSS?
Why is it necessary to have the CSS, if the div is already in the html?

Maybe because I'm new to this, I don't see the logic... Confused

Rick (shobuz99)

JeevesBond's picture

He has: 3,956 posts

Joined: Jun 2002

shobuz99 wrote: I've noticed that while editing in Dreamweaver, I must include independent files during upload, i.e. the CSS, so that the html updates properly... Why?

Am I misunderstanding the function of the CSS?
Why is it necessary to have the CSS, if the div is already in the html?

Yes it seems you are. Smiling

xhtml is the content. The text, and some containers to hold that text, e.g. [incode], [/incode] CSS is used to style those containers and that text. You use the names of those containers to apply different styles to different parts of your page. e.g. [incode]#page { background-color: #ccc; }[/incode]

Best way to explain is by example, so have a look at: http://www.csszengarden.com

Look at the xhtml code of that site, then click on a different design from the list on the right. Look at the xhtml code again: you'll see that the only thing to have changed is the stylesheet, the xhtml content is all the same. The design is completely different though.

This is the great thing about CSS and semantic markup, you keep the design and content seperate, if you need to change the design of your site: change the CSS! No need to mess around with the xhtml.

Another advantage is that as the site style isn't in the xhtml, there's less code for Google to read to get to your content. The Googlebot loves clean code! Smiling

a Padded Cell our articles site!

They have: 42 posts

Joined: Oct 2006

Thanks again Conrad for your insight and help.
Thanks also to you, JeevesBond for your examples and explanation.

I think I do understand more how the CSS file operates independently
of the xhtml code. Apparently, my issue is with DreamWeaver, as Conrad pointed out
in a chat converstaion earlier today. I've resolved to try to use text editors for code building,
and try to wean myself off of Dreamweaver MX 2004.. That may take some time! Wink

Thanks again.. to you both
Rick (Shobuz99)

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.