在HTML 5中使用表格是否合适? [英] Is it good to use tables in HTML 5?

查看:114
本文介绍了在HTML 5中使用表格是否合适?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在列式网格中显示帖子和相关数据,当然需要使用表格,因为使用浮点数在单行中对齐div是一件很费时间的事情!

I need to display post and related data in column wise grid and certainly require table for those as aligning divs in single line using floats is a time consuming thing!

感谢您对HTML的评论和不对表格的评论!

Will appreciate your reviews on Do's and Don't for Tables in HTML5!

推荐答案

简单规则 - 使用表格制作表格数据,使用其他元素进行演示(使用css设计布局),如 div 部分一边 nav 等。这为他们持有的内容提供了意义,而不是使用来处理所有事情

Simple rule - Use tables for tabular data, use other elements for presentation(designing layouts using css) like div, section, aside, nav etc . which provides meaning to the content they hold rather than using table for everything

事实是,开发人员在90年代使用表格来设计他们的布局,但现在,新的CSS3规范令人惊叹,它让你如此热衷于设计Flex Box,列数等布局,行为通过使用 box-sizing 属性可以改变盒子模型,响应式设计越来越好用 @media 使用 table 元素无法实现的查询,网格等...因此, table 仅用于存储表格数据。

The fact is, developers used tables in 90s for ddrafting their layouts, but now, new CSS3 spec is amazing, it gives you so much hold on designing layouts like Flex Box, column-count, behavior of the box model can be altered by using box-sizing property, responsive designs are getting better and better using @media queries, grids etc.. which you cannot achieve with table element... and hence, table is only used for storing tabular data.

我看到许多开发人员的印象 table 应该完全被忽略,相反,他们使用了100行CSS的 div ,应用 display:table; table-cell table-row 属性只是为了直接得到一个表。

I've seen many developers having an impression that table should be completely ignored, and instead they use a whole lot of div with 100 lines of CSS, applying display: table; table-cell table-row properties just to get a single table straight.

所以即使在HTML5完全没问题,如果你使用表格来表示表格数据 ..

So even in HTML5 it is COMPLETELY OK if you use tables for tabular data..

来自W3组织:(v4.01)


表格不应仅用作布局
文档内容的方法,因为这可能会在渲染到
非可视媒体时出现问题。此外,当与图形一起使用时,这些表
可能会强制用户水平滚动以查看在
系统上设计的具有更大显示的表格。为了最大限度地减少这些问题,作者
应该使用样式表来控制布局而不是表格。

Tables should not be used purely as a means to layout document content as this may present problems when rendering to non-visual media. Additionally, when used with graphics, these tables may force users to scroll horizontally to view a table designed on a system with a larger display. To minimize these problems, authors should use style sheets to control layout rather than tables.






From(HTML 5)


表应该不能用作布局辅助工具。从历史上看,许多Web
作者都使用HTML表格作为控制页面布局的方法
,这使得从这些文档中提取表格数据变得很困难。特别是
,可访问性工具(如屏幕阅读器)的用户可能会发现使用
作为布局的表格导航页面非常困难。如果要将表用于布局,则必须使用
标记属性 role =presentation,以便用户代理正确
代表使用辅助技术并将作者的意图正确地传达给希望从文档中提取表格数据
的工具。

Tables should not be used as layout aids. Historically, many Web authors have tables in HTML as a way to control their page layout making it difficult to extract tabular data from such documents. In particular, users of accessibility tools, like screen readers, are likely to find it very difficult to navigate pages with tables used for layout. If a table is to be used for layout it must be marked with the attribute role="presentation" for a user agent to properly represent the table to an assistive technology and to properly convey the intent of the author to tools that wish to extract tabular data from the document.

使用HTML表格进行布局有多种选择,
主要使用CSS定位和CSS表格模型。 [CSS]

这篇关于在HTML 5中使用表格是否合适?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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