use html tables for layout

This question already has an answer here:

  • Why not use tables for layout in HTML? [closed] 66 answers

  • Implementing your layout with divs, spans, etc, offers a ton more flexibility over tables. Consider floating, auto wrapping of block content vs. horizontal scrolling, specifying where an element should exist on a page, etc. Content is just plain easier to manipulate via CSS when not using tables.

    When using tables you're pretty locked in to a strict structure.

    Now that doesn't mean it's absolutely the wrong thing to do. From your information I'd likely stick with the theme of the application for consistency sake and implement using tables. Make the best choice for the situation vs. following "the rules" on what's popular right now.

    Hope that helps! Ian


    Doing css layouts make it easier to change the layout of your page later on. Tables also make your html harder to read and edit.

    According to this page..

  • make your redesigns more efficient and less expensive
  • help you maintain visual consistency throughout your sites
  • get you better search engine results when you minimize your markup and use header tags properly. This reduces ratio of code to content.
  • make your sites more accessible to all viewers and user agents.
  • your pages load faster, file sizes will be smaller because table information isn't needed in every page.
  • and give you a competitive edge (that is, job security) as more of the world moves to using Web standards.

  • I'm going to post a contrarian view, just so you have some ammo. I realize this doesn't answer your question (why not use tables) but it does address the other responses you will see.

  • The future of CSS never gets here (note: from 2005)
  • Everyone else uses tables and there are valid arguments against every response others have listed.
  • You might find some middle ground by using "display:table" to turn DIVs into TABLEs. Of course, you can't do this because IE doesn't support it until v8.
  • I read a good point somewhere: when people are referring to side-by-side columns of equal height as the "holy grail", something must be wrong with the layout engine.
  • I mean, just look at the unmaintainable contortions some people go through to make it work: negative margins, pixel counts that must correspond throughout five different rules, etc.
  • So be practical.

    That said, most of my designs use pure CSS. Nearly everything can be done in CSS just as easily as with tables (or even easier.) Start with the assumption that DIVs can do it, and maybe fall back on 1 table for a tricky multi-column layout. Even then, someone has probably found a solution for your layout so search first.

    链接地址: http://www.djcxy.com/p/15478.html

    上一篇: 桌子是否被DIV取代?

    下一篇: 使用html表格进行布局