表单输入的 HTML 表格与列表
每个人都知道您应该仅将表用于语义目的,以标记表格数据。
我个人使用有序列表来标记表单输入。
然而,我看到参数 pro 使用表格来标记表单,参数是您正在输入表格数据。
我认为这仅在非常特定的情况下才是正确的,其中输入的数据将自然地输出/表示为表格。然而我猜测这有一个缺点,它使(非常有用的)标签变得多余,因为表标签应该(理论上)代表列标题。
我想我想说的是,我认为表格形式有其缺点,但我有兴趣了解社区对使用列表与表格进行输入的优缺点的看法。
我提出这个问题的原因是 w3 规范没有提供有关标记表单的指导(据我所知)。据我所知,除非输入的数据确实适合表格数据(例如,您输入到 Google 电子表格中),否则应该主要使用列表。
这有变成战场的危险,所以请在发布之前考虑一下,也许它可能会成为一个很好的维基页面,展示最好使用每个的地方。
-谢谢 亚历克斯.
Everyone knows that you should be only using tables for semantic purposes, to markup tabular data.
I personally use ordered lists to markup form inputs.
However I have seen arguments pro using tables to markup forms, the argument being that you are inputting tabular data.
I think this is only true in very specific circumstances, where the data inputted would be naturally outputt/represented as a table. However I'm guessing this has a downside that it makes the (very useful) label tag redundant, as the table th tags should (in theory) represent the column titles.
I suppose what I'm trying to say is that I think tabular forms have their downsides, but I'd be interested in knowing what the community thinks of the pro's and cons of using lists vs tables for inputs.
The reason I bring this up, is that the w3 specs do not offer guidance (from what I can find) on marking up forms. As far as I can tell, lists should be used mostly unless the inputted data really fits tabular data (e.g. your inputting into a Google spreadsheet).
This has the danger of turning into a battleground, so please consider before posting and perhaps it may make a good wiki page demonstrating where best to use each.
-thanks
Alex.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我的规则:如果它具有类似网格的属性,并且行和列包含逻辑关联数据,那么它就是一个表格。
My rule: if it has grid-like properties and the rows and columns contain logically associated data, then it's a table.
使用表单控件和表单元素。
不要使用表格或列表。如果您的表单很复杂,您可以在 html5 中嵌套字段集甚至表单。
示例
http:// www.red-team-design.com/how-to-create-a-cool-and-usable-css3-search-box http://line25.com/wp-content/uploads/2011/form /demo/index.html 超出了我的想象。但这些甚至没有实现最低限度的控件/元素。需要字段集、标签和图例
use form controls and form elements for forms.
don't use either tables or lists. if your form is that you complex you can nest fieldsets and even forms in html5.
examples
http://www.red-team-design.com/how-to-create-a-cool-and-usable-css3-search-box http://line25.com/wp-content/uploads/2011/form/demo/index.html off top of my head. those don't even implement the minimum controls/elements though. need fieldset, label, and legend