0

Okay, so we all know we're not supposed to use tables for formatting; we're supposed to used divs and CSS; tables are for tabular data. But what is tabular data?

I run a forum for people who make model terrain.

The home page has a header, footer, menu on the left, and a space for content. These are all defined by divs and CSS... as they should be. :-)

However the content for the home page is a list of forums i.e. titles, number of topics, date of last post. Tabular data methinks?

Click on a forum and you get a page whose content is a list of topics i.e. topic titles, number of posts, date of last post. More tabular data?

Click on a topic and we have a page whose content is effectively split into two columns; the first contains the poster name, avatar, posters rank, etc, The second column contains the post itself. There are also "rows" that contain buttons to quote a post, report a post as abusive, etc.

I'm guessing that, at a first glance, most people would define the first two as tabular data. The third... hmm... I think opinions might be divided?

My forum software is a hugely modified form of phpBB. So modified in fact that the code is barely recognisable as phpBB. I mention it because it, and as far as I'm aware, phpBB, and pretty much every other piece of bulletin board software I've seen, uses tables for this stuff. So the fact that my site uses tables for all three of the page types I've described is inherited from the original phpBB code as opposed to being a decision I've made.

I also observe that most e-commerce software (including mine, that I use on other sites) uses table to "format" list of products on catalogue pages. I like to keep an eye on what the "big boys" are doing with things like this and have observed that Amazon appear to be using divs for their product lists while eBay 'still' uses tables.

I've had a good look around the web for information on what's regarded as best practice and while there's a consensus that tables should only be used for tabular data and not for formatting, I am yet to see a definition of "what is tabular data" and specifically: at what point tabular data becomes content that should be formatted with divs.

On a similar note: there also seems to be a consensus that input forms such as login screens should be formatted with CSS (although it's a damned site easier to do it with a table). It seems odd to me that a form with two titles (for username and password) and a couple of entry fields is NOT tabular data. Yet if we were to design a screen to retrieve and display that information... well then it would be tabular data would it not? And if not, then what the heck IS tabular data? ;-)

Despite the last couple of sentences, this is a serious question and I'd like to know where other programmers draw the line with regard to what is, and what is not, tabular data.

4

1 回答 1

2

这些信息应该对您有用:W3C 表格数据定义

如何使用表格最终取决于您。但是,如果您希望符合 w3c 标准,表格应该可以帮助用户理解数据。

考虑可访问性:如果使用屏幕阅读器的人遇到您的表格,该表格会帮助他们理解数据还是进一步混淆他们?

没有摘要属性或没有 th 或 thead/tfoot 元素的表格可能会使用户感到困惑。

包含任何类型脚本的表都会使用户感到困惑。

td 元素的内容需要进行视觉格式化才能理解,这可能会使用户感到困惑。

如果您不确定一组数据是否为表格数据,则它可能不是表格数据。还有其他方法可以格式化更易于访问且更符合标准的内容。

于 2013-07-29T14:37:28.040 回答