开发者

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 an开发者_高级运维d 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?


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.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜