“表格数据"的正确定义在 HTML 中 [英] Proper definition for "tabular data" in HTML

查看:34
本文介绍了“表格数据"的正确定义在 HTML 中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个迂腐的论点需要解决.

I have a pedantic argument that needs resolution.

作为一个适当的 koolaid 饮用者,当谈到 HTML 时,我完全是关于语义标记的.因此,我当然讨厌看到不属于它们的表格.表格的经验法则是,您应该只将它们用于表格数据",但我注意到这是一个定义不明确的短语.我想将以下数据制作成表格,但我办公室的其他人不同意在这种情况下表格在语义上是正确的(而不是 dlul 等):

As a proper koolaid drinker when it comes to HTML, I'm all about semantic markup. As a result, of course I hate to see tables where they don't belong. The rule of thumb for tables is that you should only use them for "tabular data", but it has come to my attention that this is a really poorly defined phrase. I wanted to make the following data a table, but others at my office disagreed that a table would be semantically correct in this case (as opposed to a dl or ul, etc):

------------------
| SomeEmployee   |
|----------------|
| Field    | val |
| Field    | val |
| Field    | val |
| Field    | val |
------------------

询问办公室(和互联网),我得到了以下关于数据表格化"的一些答案:

Asking around the office (and the interwebs), I got some of the following answers on what makes data "tabular":

  • 您可以放入电子表格中的任何内容"(我看过在电子表格中创建的整个设计模型,所以这对我来说似乎有些欠缺)
  • 可以很好地映射到数据库表的数据(例如行和列数据)
  • 文本、预先格式化的文本、图像、链接、表单、表单域、其他表格等."(感谢 W3C,这真的很有帮助)
  • "Anything that you would put in a spreadsheet" (I've seen entire design mockups created in spreadsheets, so this seems somewhat lacking to me)
  • Data that would map well to a database table (e.g. row and column data, specifically)
  • "Text, preformatted text, images, links, forms, form fields, other tables, etc." (thanks W3C, that's really helpful)

等等等等.这些似乎都不是规范定义,也没有提供很好的分界线来做出决定.所以,我问你,我聪明的同胞们:我们应该如何定义表格数据.

And so on and so forth. None of these seem to be canonical definitions, and they don't provide great dividing lines to make decisions on. So, I ask you, my clever compatriots: how should we define tabular data.

如果可能,请引用您的答案的来源,以防止出现一连串我认为"的答案.

If at all possible, please cite the sources for your answers to prevent a string of "well I think" answers.

谢谢!

推荐答案

维基百科在其内部文章写作指南中有一些实际的规则.它们远非详尽的定义,但在 IMO 的实际使用中运行良好.

Wikipedia has some down-to-earth rules in its internal article-writing guidelines. They're far from an exhaustive definition but work well in real-world use IMO.

整个定义都值得一读,但有一段让我觉得特别好:

The whole definition is worth reading, but one paragraph strikes me as especially nice:

在以表格形式格式化列表之前,请考虑是否会因为具有行和列而更清楚地传达信息.如果是这样,那么桌子可能是一个不错的选择.如果行和列没有明显的好处,那么表格可能不是最佳选择.

Before you format a list in table form, consider whether the information will be more clearly conveyed by virtue of having rows and columns. If so, then a table is probably a good choice. If there is no obvious benefit to having rows and columns, then a table is probably not the best choice.

这篇关于“表格数据"的正确定义在 HTML 中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆