element instead of ?

2019-02-13 22:58发布

Duplicate of:


Theres been a lot of talk lately about rather using div than table tags to make your pages more browser fiendly. Why is div better?

9条回答
对你真心纯属浪费
2楼-- · 2019-02-13 23:21

a few reasons:

1) div is more semantically correct in most cases. people who code their sites in table structure aren't using tables for what they're made for, which is tabular data. divs represent a "division" or a section of the page, so putting items in divs is more correct.

2) divs are more flexible and easier to style and maintain. you don't have to write <table><tr><td>Text here</td></tr></table> every time you want to say something when you can just write <div>Text here</div> instead. you can add css hooks (ie, classes or elements) to both tables and divs, but with divs it is infinitely more flexible.

3) table structured sites are just plain ugly :)

查看更多
时光不老,我们不散
3楼-- · 2019-02-13 23:21

Because a table conveys a semantic meaning - being that you're currently displaying tabular data just like h1 means you have a heading. So if you use tables to format your output you are misleading the interpretation of the semantics of your code.

This can for example lead to accessibility issues for people using a screen reader.

查看更多
Melony?
4楼-- · 2019-02-13 23:21

I am using CSS and tables and sometimes DIVs, but the tables are so comprehensive! And they look so nice in Dreamweaver, Frontpage... It is so hard to give tables up, but it seems like I will, because it is necessary to make my pages load faster!

查看更多
不美不萌又怎样
5楼-- · 2019-02-13 23:24

I tell you my personal main reasons for using divs:

  • Tables have just a static grid whereas divs are dynamic: A table's first row defines all cols (like in MS Excel). In the next rows you just can combine those cols but you can't change the basic layout you have defined within your first row. Divs are dynamic: you can create a patchwork, letting divs overlap or put some space between. Whatever you want. You are not forced to think in rows. You are free. Much more flexibility.

  • Tables cause rendering and cross-browser incompatibility problems: Tables don't look always identical. Each browser gives you its own interpretation of the table and its content. Thus, a lot of uncomfortable surprises. One browser shows you your regular text as bold font. Another browser gives your table more or less margin to other html elements, hence, the tables aren't well positioned. It's hours of work to fix these problems with complicated workarounds. Divs always look the same in all browsers. Even the IE (who is well-known as a troublemaker to webprogrammers) is causing less problems if you are using divs.

  • Divs render faster: Divs load faster than tables. Faster browsing between pages. Better look and feel.

Hope it helps. Cheers.

查看更多
迷人小祖宗
6楼-- · 2019-02-13 23:26

Using div is better than using table because of easy control of the in the design and it can be container for controls than table and the table is mainlt used to group data with simillar structure so it's design is for this task but div is considered as container mainly than table. I have found the difference between when gathering many controls and in the i can control the container but in table i got confused because i have to insert inside and its looping inside each other.

查看更多
虎瘦雄心在
7楼-- · 2019-02-13 23:27

most people goes on about how table is supposed to be used for data only and it introduces performance problem when you use it for layout purposes. Also, it is supposed to be more flexible because you can make <div> flow left, flow right and flow everywhere else.

However, IMHO it doesn't worth the effort. Especially when you have columns of controls that are supposed to line up properly with their corresponding labels, it just takes too long to get things to line up properly.

查看更多
登录 后发表回答
向帮助了您的知道网友说句感谢的话吧!