by Anthony Ng

由Anthony Ng

<table>偏见和HTML仇外心理 (<table> prejudice and HTML xenophobia)

I was looking over some HTML with a student the other day when we stumbled onto a <table>.

前几天,当我偶然发现一个<table>时,我正在和一个学生一起看一些HTML。

It displayed data with restaurant reservation information. The first column held the names for the reservation. The second column held the time of the reservation.

它显示了带有餐厅预订信息的数据。 第一列包含预订的名称。 第二栏是保留时间。

It looked like this:

它看起来像这样:

“Oh wow, I can’t believe this code is actually using a table. What is this, the 90's?” — my student

“噢,我真不敢相信这段代码实际上是在使用表格。 这是什么,九十年代?” —我的学生

Back in the 90’s, tables were all the rage. Developers would use tables throughout their HTML to format non-tabular content.

上世纪90年代,餐桌风靡一时。 开发人员将在整个HTML中使用表格来格式化非表格内容。

But the pendulum swung back. Tables fell out of fashion. And their reputation as a user interface element has never recovered.

但是钟摆向后摆动。 桌子不合时宜。 他们作为用户界面元素的声誉从未恢复。

So my student started brainstorming of ways he could code this reservation information the “right” way.

因此,我的学生开始集思广益,以一种“正确”的方式来编码此预订信息。

“I know — we’ll use lists.”

“我知道-我们将使用列表。”

“OK.” I said. “So you would use two lists? One for the name, and one for the time?”

“好。” 我说。 “因此,您将使用两个列表? 一个叫名字,一个叫时间?”

“Yes. And I’ll use CSS to style it to look like a table.”

“是。 我将使用CSS对其进行样式设置,使其看起来像表格。”

His distaste for tables and the ways they’d been abused in the past was leading him to abuse a different HTML element instead.

他对表的厌恶以及过去滥用表的方式导致他滥用了另一个HTML元素。

And this got me thinking: are other developers bending over backward to avoid using tables as well?

这让我想到:其他开发人员是否也向后弯腰以避免使用表?

为什么要使用表格? 他们是干什么的? (Why use tables? What are they for?)

According to Mozilla Developer Network’s documentation, tables present tabular data.

根据Mozilla开发人员网络的文档,表提供表格数据。

I like to think of tabular data as data that has relationships within it. Was there a relationship between each reservation? Yes, each reservation time was associated with a specific name.

我喜欢将表格数据视为内部具有关系的数据。 每次预订之间有关系吗? 是的,每个预订时间都与一个特定名称相关联。

It’s totally appropriate and semantic to use tables to represent tabular data. CSS Frameworks like Bootstrap even support styled tables. Tables are meant to be used!

使用表来表示表格数据是完全适当和语义的。 像Bootstrap这样CSS框架甚至都支持样式表。 必须使用表格!

So where did all this hate come from?

那么所有这些仇恨是从哪里来的呢?

Back in the day, tables were used for formatting and layout purposes. Take a look at this example (or view it interactively on Codepen):

过去,表格用于格式化和布局目的。 看一下这个例子(或在Codepen上交互查看):

<table align=”center”>  <tbody>    <tr><td>Welcome to this email</td></tr>  </tbody></table><table>  <tbody>    <tr>      <td>        Lorem ipsum dolor sit amet, consectetur adipiscing elit.    Vestibulum aliquet velit at lectus sodales, sit amet consequat odio eleifend. Fusce accumsan sed eros convallis imperdiet. Donec at dignissim nibh.       </td>      <td>        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum aliquet velit at lectus sodales, sit amet consequat odio eleifend. Fusce accumsan sed eros convallis imperdiet. Donec at dignissim nibh.       </td>    </tr>  </tbody></table><table align=”center”>  <tr><td>Thank you for reading this email</td></tr></table>

These 3 tables created this 2-column layout for us.

这3个表格为我们创建了这种2列布局。

With modern advances in CSS, we don’t need to use tables as a hack for page layout. Take a look at this rewritten example using CSS which produces the same 2 column layout (view on Codepen):

随着CSS的最新发展,我们不需要将表格用作页面布局的工具。 看一下使用CSS重写的示例,该示例产生相同的2列布局(在Codepen上查看 ):

// html file<header>  Welcome to this email</header>
<div>  <p>     Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum aliquet velit at lectus sodales, sit amet consequat odio eleifend. Fusce accumsan sed eros convallis imperdiet. Donec at dignissim nibh.  </p>  <p>    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum aliquet velit at lectus sodales, sit amet consequat odio eleifend. Fusce accumsan sed eros convallis imperdiet. Donec at dignissim nibh.   </p></div>
<footer> Thank you for reading this email</footer>
// css fileheader,footer {  text-align: center;}
div {  display: flex;}

表格布局不会消失 (Table layouts aren’t going away)

Your stomach might wrench when looking at that code using tables for layout. But this technique isn’t going away any time soon.

使用表格进行布局查看该代码时,您的肚子可能会感到不知所措。 但是这种技术不会很快消失。

Many developers find cross-browser testing to be difficult, but consider how many different email clients there are.

许多开发人员发现跨浏览器测试很困难,但要考虑有多少个不同的电子邮件客户端。

Email clients lack strong, consistent support for certain CSS styles. Tables provide a reliable way to achieve a consistent layout across multiple email clients and devices.

电子邮件客户端缺乏对某些CSS样式的强大而一致的支持。 表提供了一种可靠的方法,可以在多个电子邮件客户端和设备之间实现一致的布局。

学习您HTML (Learn your HTML)

My advice is to get a feel for which tools are available to you. Most importantly, use the correct tool for the job. Sure, you could use a hammer to drive a screw into a wall. But wouldn’t a screw driver work better?

我的建议是让您了解可以使用哪些工具。 最重要的是,使用正确的工具进行作业。 当然,您可以使用锤子将螺钉拧入墙壁。 但是螺丝刀不会更好地工作吗?

Many of us developers will happily investing time in learning advanced JavaScript features, algorithm optimizations, and new frameworks. But when it comes to HTML elements, most of us stick with what’s already comfortable.

我们中的许多开发人员将很乐意花时间在学习高级JavaScript功能,算法优化和新框架上。 但是当涉及到HTML元素时,我们大多数人坚持使用已经很舒适的东西。

Have you ever consider learning about HTML elements beyond the old standbys: <div>, <span>, <h1>, and <p>?

您是否考虑过学习除旧备用记录之外HTML元素:<div>,<span>,<h1>和<p>?

For example, there’s the <dl> element, which might be useful when writing a glossary.

例如,有一个<dl>元素, 在编写词汇表时可能很有用。

Then there’s the <time> element. It will allow browsers to schedule events to your user’s calendar.

然后是<time>元素。 它将允许浏览器将事件安排到您的用户日历中。

Were you about to use the <b> element to make something look important by making it bold? Consider using the <strong&gt; element instead. Screen readers don’t communicate styling to the users. But they would communicate the semantic meaning of the <strong> element.

您是否打算使用<b>元素将其变为粗体,从而使其看起来很重要? 考虑使用<strong& gt; 元素代替。 屏幕阅读器不会将样式传达给用户。 但是他们会传达<strong>元素的语义。

Are you importing a library to get a color picker or calendar on your screen? Consider using <input type=”color” /> or <input type=”date”> to use what the browser gives you.

您是否要导入库以在屏幕上显示颜色选择器或日历? 考虑使用<input type =“ color” />或<input type =“ date”>来使用浏览器提供的功能。

Take a moment to familiarize yourself with some of the HTML elements that are available to you.

花一点时间来熟悉一些可用的HTML元素 。

And next time you’re working HTML, ask yourself whether you’re reaching for the right tool.

下次您使用HTML时,请问自己是否正在寻找合适的工具。

翻译自: https://www.freecodecamp.org/news/table-prejudice-and-html-xenophobia-30704984785e/

table偏见和HTML仇外心理相关推荐

  1. Community宣言

    Community宣言 一个幽灵,共产主义的幽灵,在欧洲游荡.为了对这个幽灵进行神圣的围剿,旧欧洲的一切势力,教皇和沙皇.梅特涅和基佐.法国的激进派和德国的警察,都联合起来了. 有哪一个反对党不被它的 ...

  2. AI 2000上榜学者秦兵:走进计算机的情感世界

    6月21日,由北京智源人工智能研究院主办的2020北京智源大会成功开幕,来自世界人工智能领域的中外顶尖学者专家通过视频在"云上"相聚,共同探讨人工智能前沿问题.畅想AI发展的下一个 ...

  3. 链栈的入栈和出栈代码_代码简介:全栈开发仍然有效

    链栈的入栈和出栈代码 Here are three stories we published this week that are worth your time: 这是我们本周发布的三个值得您关注的 ...

  4. 格林尼治标准时(GMT)与世界时(UTC)

    GMT(Greenwich Mean Time)--格林尼治标准时间,格林尼治标准时间是19 世纪中叶大英帝国的基准时间,同时也是事实上的世界基准时间.当时主要为了1840 年之后的铁路系统服务.它以 ...

  5. 当你对一个聊天机器人敞开了心扉

    ▼ 点击上方蓝字 关注网易智能 聚焦AI,读懂下一个大时代! [网易智能讯 2月2日消息]几个月前,凯特·普客给她的朋友Jasper发了一条信息,内容与她的同事有关.普客19岁,在她的家乡华盛顿州斯波 ...

  6. 数学天才_数学天才是脆弱的。 我们需要停止破坏它。

    数学天才 by Junaid Mubeen 通过Junaid Mubeen 数学天才是脆弱的. 我们需要停止破坏它. (Mathematical genius is fragile. We need ...

  7. 开源许可证:复盘2019;文化的争夺才是开源的切肤之痛;等开源之道每周评论2020 03 02...

    ▼ 更多精彩推荐,请关注我们 ▼ 声明:本站言论,仅代表我自己,不管任何其它! 文 章 评 论 文化争夺才是开源的切肤之痛 原文链接:The culture war at the heart of o ...

  8. AI动漫作画强势来袭,漫画艺术将遭遇重创?

    回看2022年AIGC的发展轨迹,8月底AI作品<太空歌剧院>在美国科罗拉多州博览会(Colorado State Fair)艺术比赛中斩获头奖,人类画师愤愤不平,AIGC行业被迅速卷入舆 ...

  9. 好心情:为什么精神疾病患者往往不承认自己有病?

    生活中,当我们身体不舒服时,会意识到自己生病了,并接受相应的治疗.然而对于大多数精神疾病患者来说,他们往往不愿承认自己有病,更不愿接受治疗.为什么会这样呢?出现这种情况时,家属又该怎样做?今天好心情小 ...

最新文章

  1. 13-计算最长英语单词链
  2. 专访王劲:我和百度不一样
  3. MySQL 数据库常用存储引擎的特点
  4. 理解Node.js(译文)
  5. wireshark1.8捕获无线网卡的数据包——找不到无线网卡!
  6. Java 高并发下的实践
  7. amazon 设计 4 vending machine
  8. 小试MemSQL (The World's Fastest Database?)
  9. 遇见低码:在价值中审视
  10. python基础教程pdf-Python基础教程(第3版) PDF高清完整版免费下载|百度云盘
  11. 程序员面试金典——9.9n皇后问题
  12. CentOS 5.X MySQL5.5.35 编译的bug
  13. 计算机二级access无忧考吧破解,无忧考吧access模拟考试软件
  14. 《东周列国志》第五十六回 萧夫人登台笑客 逢丑父易服免君
  15. oh-my-zsh主题添加命令显示执行时间和当前时间
  16. API接口错误码设计最佳实践
  17. 5G商用元年开启万亿市场, 25G服务器端口出货量大幅增长
  18. 工厂方法模式(雷锋依然在人间)
  19. 使用ROSE鉴定超级增强子
  20. 第三章 区块链技术架构与发展趋势

热门文章

  1. 直接上干货!技术水平真的很重要!复习指南
  2. zookeeper的四种类型的节点
  3. 实验五 网络编程与安全-----实验报告
  4. Mysql(三) Mysq慢查询日志
  5. APUE学习之三个特殊位 设置用户ID(set-user-ID),设置组ID(set-group-ID),sticky...
  6. 锁大全与 GDB调试
  7. spring-DataSource
  8. 隐藏Content-Location标头带的内部IP地址的执行语句以及其可能会带来的问题
  9. Linux: centOS6.5 RabbitMQ
  10. [WPF]ListView点击列头排序功能实现