Differences and Connections Between DIV and Table Page Layouts
There is currently a debate over whether to use traditional Table or the newer DIV for web page design. Some say Table is better – faster to develop, easier to control, and better browser compatibility. Others believe DIV is better and represents the future trend, mainly for the following reasons:
- DIV+CSS layouts save page code compared to Table layouts, and the code structure is cleaner and more readable.
- DIV+CSS development is faster than Table with more precise layouts, though hand-written code increases noticeably. DIV+CSS layouts make website layout modifications simpler.
- DIV+CSS layouts can adapt to future multi-client requirements.
- DIV+CSS layouts save site storage space and bandwidth. These are all advantages of DIV.
With so many benefits of DIV, you might be tempted to learn it. DIV and Table each have their strengths, and in most cases they can be used interchangeably. I believe the correct standards-compliant design philosophy is: use DIV and other layout elements to create page design layouts, positioning, color blocks, images, etc. Use Table, UL, and similar elements to display data on the page. Because DIV does not behave like Table in IE, where the entire Table must be downloaded before any content is displayed (Firefox does not have this issue), using Table for layout is clearly not ideal, especially with large amounts of data – it is noticeably slower in IE. DIV handles this much better. Of course, DIV can also serve to organize data.
DIV for layout, Table for displaying data – this is the most fundamental design principle today.
Can a Table contain a DIV? And vice versa, can a DIV contain a Table?
Of course it can.Does DIV serve the same purpose as Table?
DIV’s functionality is similar to Table, but DIV has better XML support and is more flexible to use, which is why it is recommended as the new approach for web page layout.Which is faster, DIV or Table?
DIV is relatively faster. Web content display requires downloading a complete block of content before rendering. DIV layout consists of many independent, relatively small blocks, while Table layout typically involves multiple layers of nested tables forming larger download blocks.
Additionally, the difference between . and # in CSS:
.is called using class#is called using id