Table vs Div

by 12 replies
15
I read on various webdesign websites that table is a very crude way to center html elements...

However, if I use div I'm afraid that different browsers will not interpret the css rules the same way.

What do you (or your web designer) use? : )
#website design #div #table
  • i have try <div align="center> or with margin: 0px auto;
    it works on opera and firefox, but in ie i must use <center></center> to make it centered-align
    • [1] reply
    • if you give the div a width, it will work in IE

      so something like

      <div style="width: 400px; margin: 0 auto;">
      would work in all browsers
      • [ 1 ] Thanks
      • [1] reply
  • Div makes your Page alignment, Table makes perfect position
    • [ 1 ] Thanks
  • in the div add the style
    margin:0 auto;

    and for some browsers like IE 6 you have to use this rule for body html tag <body style="text-align:center;">
    • [ 1 ] Thanks
    • [1] reply

    • yes that works...God I how I hate developing for IE
  • Tables are for tabular data, not to structure a website. There are WAY too many websites out there with tables, and some still being designed using tables. CSS is what needs to be used.
  • Div is perfect. forever.
  • tableless design is faster, more compatible and good for seo.
  • One simple method to center a div structure is to create a div element to "wrap around" all the other elements, and center it with CSS. I normally call this div box for wrapper, and assign CSS rules to it to give it its dimensions and position.

    Example:

    HTML:
    <div id="wrapper">

    <div class="content">
    </div>

    </div>

    ---
    CSS:
    #wrapper {
    text-align: left;
    height: 900px;
    width: 900px;
    margin-top: 0;
    margin-right: auto;
    margin-bottom: 0;
    margin-left: auto;
    }

    container {
    height: 900px;
    width: 900px;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    }

    Hope that made sense
    • [ 1 ] Thanks

Next Topics on Trending Feed

  • 15

    I read on various webdesign websites that table is a very crude way to center html elements... However, if I use div I'm afraid that different browsers will not interpret the css rules the same way.