表格数据的 Div 与 Table

发布于 2024-11-19 01:22:51 字数 142 浏览 2 评论 0原文

是的,另一个 div 与表格问题...

我到处读到“尝试使用 div 而不是表格”,但我有一个显示表格数据的应用程序,基本上我的整个 Web 应用程序显示表格(具有不同的列)和数据)但一切都是表格......我应该使用斗争来使用div吗?如果是,为什么?

Yes, another divs vs tables questions...

I read all over the place that "try to use divs instead of tables", but I have an application that displays data that is tabular, basically my entire web application displays tables (with different columns and data) but everything is tabular... Should I use struggle to use divs? If yes, why?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

暗地喜欢 2024-11-26 01:22:51

使用表格来获取表格数据。当桌子仅用于布局目的时,就会受到冲击。他们有自己的目的,那就是表格数据。 Div 没有语义意义,不应用于表格数据。

Use tables for tabular data. The knock against tables has been when they've been used solely for layout purposes. They have their own purpose, and it's tabular data. Divs have no semantic meaning, and shouldn't be used for tabular data.

少女净妖师 2024-11-26 01:22:51

不!
如果您的代码根本不使用表格,那么它们就会被删除。表格有其正确的用途,而且是用于表格数据!现在是使用它们的时候了(不是用于演示或设计)。所以无论如何,使用表格!

我建议在表格中提供标题标签,以便为可能使用屏幕阅读器的人(例如盲人网上冲浪者)提供适当的上下文。

示例:

<table>
    <caption>Corporate Information of Current Employees</caption>
    <tr>
        <td class="employeeName">Jim Jones</td> 
...

不要害怕当前的趋势。表格应该用于表格数据。您做得对:)

深入了解辅助功能还提供了许多有用的提示。

No!
If tables were not to be used at all for your code, they would have been taken out. Tables have a proper use, and that use is for tabular data! This is the time to use them (not for presentation or design). So by all means, use tables!

I would recommend to provide a caption tag within your tables to give people who may be using screen readers (such as blind Web surfers) proper context, too.

Example:

<table>
    <caption>Corporate Information of Current Employees</caption>
    <tr>
        <td class="employeeName">Jim Jones</td> 
...

Don't be afraid of current trends. Tables should be used for tabular data. You're doing it right :)

Dive Into Accessibility offers a lot of helpful tips, as well.

池予 2024-11-26 01:22:51

用 CSS 正确标记的表格没有任何问题。对于表格数据,表格是自然的选择,不要尝试使用 div 来模拟它们;除了少数情况下 div 可以更干净。

Div 和表格都只是您可以使用的工具。了解何时为正确的工作应用正确的工具。

There is nothing wrong with tables correctly marked with CSS. For tabular data, tables are natural choice, don't try to emulate them using divs; except in few cases where divs can be cleaner.

Divs and tables are both just tools at your disposal. Learn when to apply right tool for the right job.

那小子欠揍 2024-11-26 01:22:51

不,您必须使用表格来存储表格数据!表格就是为了这个目的而存在的,您必须使用 div 来避免表格仅用于布局目的。

No, you MUST use tables for tabular data! Tables exist for that purpose, you MUST avoid tables only for layout purposes by using divs instead.

只有一腔孤勇 2024-11-26 01:22:51

不要使用表格作为“布局”,因为您已经在网上找到了很多原因。
但为了显示“数据”,您仍然可以使用表格。

大多数服务器端脚本语言(例如 ASP.NET)都会为 gridView 生成表格,因此它们并不是“使用绝对错误”。

对于布局,我建议您浏览人们在 CSS Zen Garden 中为“单一 HTML”设计的不同有趣布局。

Don't use tables for your "LAYOUT" because of many reason you've already found on web.
But for displaying "DATA" you still can use tables.

most of server side scripting languages like ASP.NET generate tables for gridViews so they are not "Absoutely wrong to use".

For layout I recommend you going through different insteresting layouts people have designed for a "Single HTML" in CSS Zen Garden.

把回忆走一遍 2024-11-26 01:22:51

我不认为你应该努力使用 div,因为我个人不会,但也许这会有所帮助。

为什么不在 HTML 中使用表格进行布局?

I don't think you should struggle to use div's because I personally wouldn't but maybe this will help.

Why not use tables for layout in HTML?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文