PDA

Click to See Complete Forum and Search --> : Couple quick questions for the web pros


dyers78
08-29-2006, 09:38 PM
ok. I bought a book on CSS and am LOVING IT. I just need to wrap my mind around it and do a simple project to see it work.

1. Is a <div> basically just a chunk of content? Is this different from a "layer" or the same thing with two names.

2. when you code a style sheet, can you do that in notepad or what ever and then just save it with a .css? If not how do you put one together from scratch?

Thanks Ya'll -

chris_bcn
08-29-2006, 10:14 PM
The key to Table-less design is divide your page into semantic chunks.

A <div> is a division (hense the name) - generally speaking (and there are many ways to do this) a basic 2 column blog type site would have a structure along these lines

<div id="container">
<div id="header">This is where the header and the logo etc. go</div>

<div id="sidebar">This is the sidebar - generally holds navigation.
This can be on the left or right
</div>

<div id="content">
beautfully crafted pearls of wisdom go here
</div>
<div id="footer">copyright etc.</div>
</div> <!-- THE END OF THE WRAPPER DIV - the wrapper div hold everythign together - it wraps around the content and nav-->

chris_bcn
08-29-2006, 10:15 PM
the CSS can be created in any text editor and saved with a CSS extension (although this isn't strictly necessary, it's good practice to do so)

dyers78
08-29-2006, 11:29 PM
so the div is different than a "layer"? and is what you listed the only div tags you would have or would there be several bepending on the amount of content.


Two more questions... am I pressing my luck yet?

1. If you put together a poorly designed style sheet and assign the styles to a ton of elements throughout a site, how do you clean the mess up? If you change the style names (which are randomly named based on the task at hand) the stlye names would all be bunk if relinked... this is a messy question. Would I have to go throught the entire site and reassign the correct names?


2. Those that hand code - How to you mange a huge site? The thing I love most about GoLive is the site manager. just curious.

Thanks Chris

tZ
08-29-2006, 11:57 PM
A <div> is just a division- thats it.

Take this mark-up for example:


<body>
<div>
<p>this is a sentence</p>
</div>
</body>


In a browser that would render no differently then if I were to use this mark-up instead:


<body>
<p>this is a sentence</p>
</body>


The only difference is that the first example contains a division which I can add universal styles to.

What I mean by that is lets go back to your example and say I had a bunch of different elements within my div. If that was the case then I could target my div and apply a universal style change to every element within the div. Where as, if they weren't in a division I would need to target every element individually.

That is really all a div is. Abstratctly, a div is just a division or "container" that groups elements together giving them the same parent- the div. Which you can refer back to in order to make style changes throughout every child- element within the div.

Non abstratctly, a div is a box- a block level element so to speak.

In CSS there are only two general types of elements

- block
-inline

A block element is any element that can contain other elements(block or inline).

Here is a list of block level elements:

- h1,h2,h3,h4,h5,h6
-p
-div
-blockquote
-ul and ol

Now a inline element is one which is contained within a block element but, can not contain a block itself only more inline elements

Here is an example of inline elements

em
strong
cite
a

For your *first* question I would have to say you restructure the mark-up so it is semantic then use descendent selectors to apply styles.

For instance, I know when I first got into this whole CSS thing I loved my divisions and ids. However, you should allways use them sparingly and instead use descendent selectors to target items. This will both decrease the size of your files and amount to less promblems with the cascade latter on.

Descendent selection are all based on the document object model- or the hierachy of a document.

For instance take this bit of mark-up:


<body>
<div id= "navigation">
<ul>
<li><a href="">linkone</a></li>
<li><a href="">linktwo</a></li>
<li><a href="">linktwo</a></li>
</ul>
</div> <!-- navigation -->
</body>


That is just a list with links.

So if I wanted to have links appear in red I could just do this:


a {
color: red;
}


However, now if I have any other links in the entire design they will also appear in red. The way I fix this is to use descendent selectors and get as specific as possible like so:


#navigation ul li a {
color: red
}


Now my links will only be styled if they have a list item parent whose parent is a unordred list whose parent is the div navigation.

For the second question I would recommend naming your folders and sire components to well describe what they actually are. Textwrangler is a good texteditor to download with the view like dreamweaver.

dyers78
08-30-2006, 01:19 AM
wow! Thanks... are you tired of typing yet? I'm geting this, will take a little time though. Thanks, that helped.

EC
08-30-2006, 01:34 AM
1. If you put together a poorly designed style sheet and assign the styles to a ton of elements throughout a site, how do you clean the mess up? If you change the style names (which are randomly named based on the task at hand) the stlye names would all be bunk if relinked... this is a messy question. Would I have to go throught the entire site and reassign the correct names?

Basically, don't rename things in your stylesheet. Look to create your own naming conventions though. Nothing is random unless you're using the program to create the styles for you. Use descriptive names like .title or #wrapper or #main or .subTitle etc.

I don't really know what you mean by relink.

When you first start, there will be mess. But you'll learn over time how to make cleaner code, how to work the cascade, etc. I'm still learning how to clean things up, believe me. :)


2. Those that hand code - How to you mange a huge site? The thing I love most about GoLive is the site manager. just curious.

Thanks Chris

I use dreamweaver for site management. There's nothing wrong with that - to me, these programs are best used for site management and production. You can hand code in any of these programs, notepad is something I pull up because it's handy sometimes, but why not leverage technology, there is no reason not to?

dyers78
08-30-2006, 01:37 PM
makes sence. I did my first crap-ass styling last night.... a big smile appears on face. I have not been this excited to learn in a long time. thanks aging for all the help. I will post up my first site when I'm done.

EC
08-30-2006, 01:58 PM
yay! yeah it is fun.

JPnyc
08-30-2006, 02:35 PM
A div is a generic block level container. Coding is a blast. Way more fun than golf.