2011-11-03 20:10 阅读 35

2011年:DIV还是桌子? Div / Input / Labels仍然是可行的,还是XHTML Tables(tables / tr / td)的风格? [关闭]


Here's a question for front-end developers out there. Are table-less designs still required by most projects you work, or are simple tables structures accepted again? If so, were are tables appropriate? Data? Forms?

I recall, not more than a couple years ago, a designer friend of mine told me that I had to go table-less with all my HTML/XHTML. Everrrything tables. That DIV's were the way to go. Being more of a backend PHP/MySQL developer I tried to jump on the band-wagon with a CakePHP project or two. I revamped most of the basic template pages/structures to use DIV's with CSS2.

Now that I'm doing more CodeIgniter work... well, I'm now using tables with most of my Forms. I've had some issue with Divs. Tables are so much more structured and present me with less issues (IE6). Is this considered "bad code"? The company I'm working for has an image to withhold.

Thanks, Jeff

Edit: Please don't downgrade the question. It's a legitimate question from a non-designer needing to do front-end work. Maybe I should have asked , "Where is it appropriate to use tables in XHTML/CSS2?"

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • 已采纳
    dongmimeng5500 dongmimeng5500 2011-11-03 20:15

    a designer friend of mine told me that I had to go table-less with all my HTML/XHTML.

    Tables have one defined purpose: Tabular data. For that purpose, using them was never wrong. Using divs or other elements to re-build a table for tabular data is, was, and always has been a fine example of cargo cult programming - adopting something ("Eeeek, tables are evil!") without really understanding why.

    See this SO question for attempted definitions of what constitutes tabular data: Proper definition for "tabular data" in HTML

    What they should not be used for is layouting the page. That has really come out of style, and will probably never get back in style any more, seeing as they become less and less necessary as CSS improves.

    I personally find using tables for forms totally okay, by the way.

    点赞 评论 复制链接分享