I'm totally confused on this matter, some say use tables and others say it's a bad practice to make use of tables and div tags should rather be used. What is the correct way when developing sites for mobile devices .开发者_Go百科mobi
You should use tables for presenting tabular data, not for layout. Most modern Web browsers on mobile phones (e.g. Mobile Safari on the iPhone) are quite capable of properly rendering websites that use CSS and semantic markup appropriately.
Yes, theory says that you should use tables for presenting tabular data, not for layout. But most of web browsers in the market do not properly render complex layouts with floating divs, advanced CSS, etc.
Things are changing quickly, and as other people have already said, most modern Web browsers on mobile (smart)phones (iPhone, Android...) come with a great HTML/CSS/Javascript support.
If you only have these devices in mind, you can go with DIV/CSS layouts, as it is the right choice from a semantic point of view. But if you want to cover a wide range of devices, use tables as you'll guarantee your pages are going to render properly in more devices.
The important aspect to consider is the difference between data & its actual layout on the screen.
Typically, tabular data should be presented using tables. For example, consider a company balance sheet as an example of tabular data which can be shown using HTML tables.
But, if you need to show normal content (which is not tabular in nature) in rows & columns, there are other alternatives like using DIV & SPAN tags and a bit of CSS to position & style the content to make it look like a tabular layout. A typical example of such a layout could be a news article shown on a newspaper. While the layout is in rows & columns, the news content itself is non-tabular.
There are tons of articles out there which debate why this is a good practice.
Given your case, I would recommend stick to normal DIV-based structure with CSS-based styling to give the desired effect & use TABLEs for tabular data.
HTH.
精彩评论