Why should I use display:table instead of table

前端 未结 4 1750
说谎
说谎 2020-12-09 04:09

What\'s the benefits of structuring my site with divs and apply the display:table property ( display:tr, display:tr). Doesn\'t this mean that the divs will behave exactly li

4条回答
  •  有刺的猬
    2020-12-09 04:18

    The following explains why to use DIV over TABLE elements.

    Pros of Table Element: Most designers use table for a consistent look. Tables are also easy to maintain. Another advantage of table is that it is compatible with the most browsers.

    Cons of Table Element: All this comes with a cost: Too many nested tables increase page size and download time. More table elements push important content down so search spiders are less likely to add content to search engines.

    Pros of DIV Element: div with CSS we can achieve the same table based page structure and reduce the number of elements on the page, which allows the page to load faster. It also makes page more compatible with search engine spiders.

    Cons of DIV Element: The major drawback of this is not all CSS elements are not browser compatible. Because of this we have to write some custom CSS to resolve issues.

    full article : http://www.codeproject.com/KB/HTML/DIVwebsite.aspx

    display: table tells the element to display as a table. Nested elements should be displayed as table-row and table-cell, mimicking the good old TR's and TD's. There's also a display: table-column but it should show nothing at all, only serving for style information like a COL does. I'm not sure exactly how this works.

    more about div display style : http://www.quirksmode.org/css/display.html

提交回复
热议问题