views:

113

answers:

2

I'm supposed to rewrite the UI for a rather large web application. The thing is that the layout is completely based on tables and if I could somehow, semi automatically, convert the tables into divs it would save me a huge amount of time.

What are the best practices when doing something like this? Is this a good idea at all?

The application use layout files (containing something similar to helpers) that are parsed into html at runtime and the application itself also output html at specific places. So the work will consist of converting these helpers and the htmloutput code within the application.

+3  A: 

use a CSS based table layout:

http://www.onenaught.com/posts/201/use-css-displaytable-for-layout

do a string replace, turning every , and into , respectively

add a style definition like this:

div.table { display:table; }
div.tr    { display:table-row; }
div.td    { display:table-cell; }

that way, everything should look like a table layout without actually being one

The big drawback: if you used rowspan and colspan, you're out of luck, there are no such mechanisms in CSS

seanizer
What's the benifit of doing this instead of keeping the original layout? can I use padding, margin etc. even if I add these style attributes. At this stage padding and margen is my greatest concern.
picknick
it's a minimal solution and as such causes minimal work. it turns a very bad thing into a slightly better thing (instead of starting from scratch would would probably be a lot prettier but much more work). Of course you can and should extend these css classes
seanizer
+3  A: 

The greatest benefit of avoiding tables is to use semantic markup in the HTML, and use CSS to do the layout, thus separating content from presentation.

If it is the application generating the HTML, this probably can't be achieved, and there would be little or no benefit beyond appeasing the 'tables considered harmful' style police.

I can certainly see no benefit in simply replacing <table> with <div class="table"> etc. This is a complete misunderstanding of the benefits which can come from avoiding tables for layout.

ChrisV
I agree. But in a scenario where HTML is generated all over the place (which is evil per se) it's the only alternative to re-writing everything from scratch, I guess
seanizer