The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

<div> vs. <table>

I have a question about putting stuff on a site. I have been using tables for everything and I dont see any problem with it but I have been told I should use CSS and when they say that I think "divs?", What do u guys think I should use more?

I have a question about putting stuff on a site. I have been using tables for everything and I dont see any problem with it but I have been told I should use CSS and when they say that I think "divs?", What do u guys think I should use more?

<div>'s have a few attributes that can add functionality to a site. eg absolute positioning however dont put all you tables absolutely postition as half the time its messes up on different browsers.

<div>
<table></table>
</div>

is ok, if its not used all over the place.

but why do you associate css to <div>'s, just use css directly on the table if any thing.

Well I was told to stop using tables completly and use CSS, but the only way I can think of doing that is to use <div>'s, Many people I have asked say use tables but I was just wondering what other people thought.

Your site would be easy to pull off in a completely CSS layout. The DIV element, which stands for "division," can be used to recreate table layouts most of the time. The main difference is in the document's structure, as TABLE was never meant to be used as a layout device.

You can style DIV elements using CSS, and the code will be cleaner, faster, and more standards-compliant than if you continue using tables to lay out your pages.

No, I like to use tables, I just don;t get whats different. The guy told me I should use CSS and not tables, and I don't get what he means. I read a book today and I get how to position stuff but some stuff in CSS wont work in NN so I don't get it.

Tables are meant for formatting, well, tabular data. Stuff like figures and numbers and such. Divs are just generic content containers, but CSS can be used to specify how divs should look. The DIV element in itself isn't CSS; it's just standard HTML.

The reason you want to get away from using tables for layout is because that breaks the purpose and intent of them. All newer browsers (IE5+, Op5+, Moz/NS6, etc.) handle most CSS relatively well, so you can be assured of almost the same look across them. What we're talking about here is separating content from style, and you can't really do that using tables for layout.

And, no, NS4 doesn't handle style sheets very well at all. But you can't blame it, it's about five years old. Plus, there's only a very small percentage of people who even use NS4 anymore, so I don't worry about it. I design for standards, which in turn is design for the newer generation of browsers.

See http://alistapart.com/stories/journey/ for their conversion to all css. Now alistapart has taken the 'no bad browsers' stance which is great but if your a 'compatability' doctrinaire it might make you batty.