I've until now created all my webpages in tables but have recently been thinking about starting to use divs instead.

I've been thinking about trying to convert one of my ccurrent projects (from tables) to divs - anyone that happen to know some smart way to do this (without writing all the code again from the beginning)?

Recommended Answers

All 4 Replies

I dont have an answer, but I'm fascinated by the question
I remade my tables hard
I did a lot of find and replace

<!--almost-->
<table> <div class='outer'>
</table> </div>
<tr> <div class='row'>
</tr> </div>
<td> <span class='cell'>
</td> </span>

<style type='text/css'>
.outer { width:95%; border:1px solid #000000; }
.row { border_bottom:1px solid #000000; }
.cell { width 18%; }
</style>

there were five columns in the table

Erm... It really depends what way your page is coded, and to be honest, chances are to do the job right, you'll have to code from the start. Sorry.

It would help if you posted some sample code and I could try and show you how I'd lay it out in divs and css instead...

Once you have some practice, you'll wonder why you ever coded in tables! :) Though if something needs to be in a table, say, 'a table of contents' ;) then be all means, go nuts! :)

Strategically, I would firstly being thinking of the stylish problem. To solve that I would use both "class" and "id" to mark the becoming div-tags.
I guess there must be a lot of tables in one page only and every table would be set to a certain class. Within the table, there would be a lot of table data, td, th, and so on. All of them need to have the table class but also a specific id.
When it comes to nested tables (tables within another table), I would extend the class name with an underline and a new class name, like: class="myTab_tab1" and class="myTab_tab2", and so on. The same would be able to do with id.

In the end of all this, I understand that u have a lot of files and u wish to convert all of them, it is suitable to use a tool that enforce the conversion by the naming structure I have demonstrated for u here. The secret lies in the method of structure. Since table is a certain structure, all u need is to think of how you can replica the structure with div tags. I guess there will already be advanced word processors able to apply with a batch programming type ready for you to input some conversion orders and run. In that way you can solve the problem at hand in a suitable and rather comfortable way.

that's impossible to convert it without re-coding. Because they're both completely different.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.