I'm probably not going to be able to explain this well enough in a few forum posts, but I'll give it my best. In fact, I spent an entire book of 648 pages explaining exactly this! So if you don't get it right away, no worries, most of us have spent a few years getting it down.
A <div> is what is known as a "block-level" element. In this case it is a generic container. As a block-level element it has some pre-defined rules that it must follow.
1. By default it takes up all the space available to it horizontally.
2. It expands vertically only as much as there is content inside of it.
3. Width applied to a block element is strict, if you apply a width of 200 pixels to a <div>, that width must be kept no matter how large the content it holds. (Internet Explorer does not adhear to this rule, but standards-compliant browsers [Mozilla Firefox, Apple Safari, Opera] do)
Some examples of block-level elements are[list] (unordered list), <li> (list-item), and <p> (paragraph). The names for these elements come with some more predefined behaviors that distinguishes them from the others. For instance a[list] element typically has some margin or padding applied to the left and top sides. <li> typically appear inside of[list] elements, and have bullets on the left side, together they define lists. A <p> will have some margin applied to the top. A <div> is a generic container, it has no margin, borders, padding or anything else special applied to it. But as block-level elements, they all conform to the two rules I mentioned.
A <table> is used to show relationships between data, e.g.
Code:
----------------------------------
| user | name | age | ************ |
----------------------------------
| joe45 | Joe Blow | 19 | m |
----------------------------------
| kat45 | Kathy Blow | 22 | f |
----------------------------------
A <table> has some predefined behaviors it conforms to as well.
1. A <table> expands horizontally only enough to accomodate its content, this is called "shrink-to-fit"
2. A <table> contains rows "<tr>" and cells "<td> or <th>", which structure the data inside.
3. Width applied to a <table> is not strict, the browser may stretch the <table> if the content inside of it is greater than the width specified.
4. By default, there is usually some space applied between each table cell.
There are lots of things that you can do to <div> and <table> elements that change the rules of how they are laid out, the best way to learn is to experiment, write test cases and see what is possible for yourself. Get a few books on the topic, more than one is best because that helps you to get a different perspective on the more difficult topics.
Anyway, I hope I haven't confused you more! Let us know if you have more questions.
Regards,
Rich
--
[
http://www.smilingsouls.net]
Mail_IMAP: A PHP/C-Client/PEAR solution for webmail
Author: Beginning CSS: Cascading Style Sheets For Web Design