jocke138
jocke138

Reputation: 1

Advise me against using <table>!

I'm working on a JavaScript (using HTML as display tech) widget framework for an embedded device where memory consumption is a big deal.

Recently I tried to create a table-layout using only DIVs. But to mimic the colspan and rowspan functionality it became quite complicated, adding extra logic to make it all dynamic. The result came out quite good layout-wise, but at the cost of too much memory consumption (had to have several JS objects representing each cell and then a DIV as presentation)

Wouldn't it be better to just use the TABLE element instead, getting the col- and rowspans and layout for free? Especially since all markup is crated by the framework and that the user (of the framework) never actually touches the HTML itself.

Or am I missing something here?

Upvotes: 0

Views: 126

Answers (3)

kgiannakakis
kgiannakakis

Reputation: 104188

Go ahead and use a table. One of the main reasons that CSS layouts are encouraged is accessibility (probably you don't care about). Another reason is separating content from layout - you are probably creating both. So, the disadvantages of tables are of very low importance compared to the advantages in your case.

Upvotes: 1

Alohci
Alohci

Reputation: 83006

If you start out with the mentality of "I need a table-layout", it's inevitable that you'll end up deciding that you need to use a <table>, because CSS cannot deliver on the subtleties of colspans and rowspans. But do you need a table-layout? You don't describe the underlying layout requirements, so it's impossible for us to steer you either to or from <table> except in broad generalities.

Upvotes: 2

30equals
30equals

Reputation: 329

well tables are perfectly fine for tabular data if you want to do it right semantically. And imo, you have to go for the best solution in your situation. Performance is more important than using div's or not in this case i guess.

Upvotes: 2

Related Questions