html|PHP Using Divs instead of tables. How?

Miscellaneous Forums/General Discussion/html|PHP Using Divs instead of tables. How?

I'm currently using tables to arrange everything on my kamikazekrow.com site. What's happened is that I need to make changes to the pages and it would mean editing all of them by hand so I've restarted in Dreamweaver using php and css stylesheets to build the pages. I've been told that using tables is not as efficient as using Divs but I don't know how to do that.

How do I use divs toi align everything on the website as I do with tables?

Is there any other method?

Thanks. :)

Check http://glish.com/css/

Thanks to Internet Explorer, CSS is quite fiddly to get working on all browsers; in many circumstances you can do it properly and get it working on most browsers except Internet Explorer, or you can cheat and get it to work on Internet Explorer but not the others. There are some work arounds, but it's still very fiddly.

Generally, I tend to use a mixture of CSS div tags and tables where necessary. You say that you are using PHP - some ideas:

* Why don't you split your template into separate files (like header.inc.php and footer.inc.php) and include them within each page

* Have your site as a database driven website and use the querystring from the url to tell your template what page information to get from a database

Well, they are my thoughts.

How do I use divs toi align everything on the website as I do with tables?


You don't, this is the first mistake people make when doing the transition. Tables are good for controlling layout (with flaws), but you shouldn't treat DIV's like table cells.

mockup your page then draw some boxes around the main containing portions.

see these pages for more info:

http://www.wellstyled.com/css-2col-fluid-layout.html
http://www.alistapart.com/articles/
http://www.cssbeauty.com/
http://www.csszengarden.com/


but you shouldn't treat DIV's like table cells



Unless you want to, in which case there's a "display:table;" tag as part of the spec. I also think tables are great for layout, though, and it's daft to get hung up about using them just because they happen to be called tables (which makes nerds say that they should only -- ONLY -- hold tabular data). The fact is your page will validate fine if you use tables to lay things out.

(which makes nerds say that they should only -- ONLY -- hold tabular data).


No, the W3C and disabled users say they should only hold tabular data.


W3C


That's what I said ;)


disabled users


If you want to give disabled users a comprehensible document then surely the way to do it is by serving them a file with zero markup (ie plain text). Refraining from using tables for layout seems like an empty gesture to me... the content is still going to give text-readers hell.

the content is still going to give text-readers hell.


Why's that then?


Why's that then?


Because site content is often ostensibly not aimed at disabled users? There's not much you can do to make a site full of optical illusions accesible to blind surfers.

I don't know a great deal about text-readers, mind, so feel free to put me straight, but the ones I'm aware of simply read the text you highlight (or hover). I don't see how layout tables will cause any issue at all here - their mark-up will never get read out by such software.

My view is pragmatic: Tables bring layout parity to a wider range of browsers than CSS; Tables used for layout can be denoted as such; Table layouts validate whereas hacky CSS does not... they're handy, tables. But I'm still only really thinking about fluid columns here - I mean my humble site is CSS based with a couple of tables where I eventually decided it made sense. I'm not saying "use tables for any and all layout", I'm saying "use tables where CSS makes things more complex instead of doing its damn job and simplifying matters".

I don't know a great deal about text-readers, mind, so feel free to put me straight, but the ones I'm aware of simply read the text you highlight (or hover). I don't see how layout tables will cause any issue at all here - their mark-up will never get read out by such software.


They tend to read the entire page actually, top to bottom, left to right. Which means if you have a table, it reads the data out row by row, cell by cell.


They tend to read the entire page actually, top to bottom, left to right. Which means if you have a table, it reads the data out row by row, cell by cell.



Ah, I see. To be honest, it's as likely to be wrong as right when reading actual tabular data then. For fluid columns, row by row, cell by cell is good. I'm pretty happy I've arrived at a good balance now.