table偏見和HTML仇外心理

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/

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/396077.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/396077.shtml
英文地址,請注明出處:http://en.pswp.cn/news/396077.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

回滾機制_【巨杉數據庫SequoiaDB】巨杉 Tech | 并發性與鎖機制解析與實踐

01概述數據庫是一個多用戶使用的共享資源。當多個用戶并發地存取數據時&#xff0c;在數據庫中就會產生多個事務同時存取同一數據的情況。若對并發操作不加控制就可能會讀取和存儲不正確的數據&#xff0c;破壞數據庫的一致性。加鎖是實現數據庫并發控制的一個非常重要的技術。…

Android系統源碼學習——源碼目錄結構介紹

2019獨角獸企業重金招聘Python工程師標準>>> Android 4.0源碼目錄結構: 本文介紹Android源碼目錄結構&#xff0c;以便讀者理清Android編譯系統核心代碼在Android源代碼的位置。 Android源碼體積非常龐大&#xff0c;由Dalvik虛擬機、Linux內核、編譯系統、框架代碼…

簡答題c語言文件操作順序,計算機基礎與程序設計2012年4月真題試題(02275)

計算機基礎與程序設計2012年4月真題試題與答案解析(02275)計算機基礎與程序設計2012年4月真題試題與答案解析(02275)&#xff0c;本試卷總共100分。一、單項選擇題(本大題共20小題.每小題1分&#xff0c;共20分)在每小題列出的四個備選項中只有一個是符合題目要求的&#xff0c…

匯編實驗3

1.運行如下代碼&#xff1a; assume cs:codecode segment mov ah,2 mov dl,3 add dl,30h int 21h mov ah,2 mov dl,6 add dl,30h int 21h mov ah,4ch int 21hcode endsend 進行匯編運行之后結果為&#xff1a; 將第四行和第九行的寄存器dl的值修改之后代碼如下&#xff1a; a…

聽了一堂《**學院》的課,我也是醉了

這還是首席講師的ppt&#xff0c;這說話咋感覺&#xff0c;不像是技術出身&#xff0c;反倒是MongoDB的銷售人員呢。 這說話&#xff0c;不大講相對&#xff0c;凈他媽的 絕對&#xff0c;這水平&#xff0c;我真醉了。 這牛逼吹得&#xff0c;嘖嘖嘖。 我還是看書吧。 轉載于:…

react 組件引用組件_React Elements VS React組件

react 組件引用組件A few months ago I posted to Twitter what I thought was a simple question:幾個月前&#xff0c;我在Twitter上發布了一個我認為簡單的問題&#xff1a; What surprised me wasn’t the joint confusion around this question, but rather the amount o…

appium 環境搭建(不推薦安裝此版本appium,推薦安裝appium desktop)

一&#xff1a;安裝node.js 1、雙擊這個軟件 2、一鍵安裝&#xff0c;全都下一步&#xff0c;不要私自更改安裝路徑 3、打開cmd&#xff0c;輸入npm&#xff0c;出現如下截圖表示成功 二&#xff1a;安裝appium 1、雙擊appium-installer.exe 2、一鍵安裝&#xff0c;全都下一步…

二級c語言上機題庫及解析,2013年計算機二級C語言上機題庫及答案解析(3)

填空題給定程序中&#xff0c;函數fun的功能是:在形參ss所指字符串數組中&#xff0c;查找含有形參substr所指子串的所有字符串并輸出&#xff0c;若沒找到則輸出相應信息。ss所指字符串數組中共有N個字符串&#xff0c;且串長小于M。程序中庫函數strstr(s1, s2)的功能是在 s1串…

js 數組遍歷符合條件跳出循環體_C++模擬面試:從數組“緊湊”操作說開來

面試官自來也去掉一個字符串中的空格。假設用C語言來解答&#xff0c;字符串是char數組。O(n)時間復雜度實現不難&#xff0c;比如額外申請一個新數組&#xff0c;然后遍歷一遍字符串&#xff0c;將符合條件的字符存儲到新數組中&#xff0c;實現起來很簡單。但這顯然不能讓面試…

項目NABCD的分析

N&#xff1a;你的創意解決了用戶的什么需求 本項目解決了在校大學生和社會工程人士在計算一些工程測量中的需求&#xff0c; 可以通過自己提供的一些測得的已知數據來推算出自己想要的數據結果&#xff0c; 比用戶自己手動計算更有效更快更節省時間 A&#xff1a;有什么招數來…

git 命令git 地址_這是我上周使用的所有Git命令及其作用。

git 命令git 地址by Sam Corcos由Sam Corcos 這是我上周使用的所有Git命令及其作用。 (Here are all the Git commands I used last week, and what they do.) Like most newbies, I started out searching StackOverflow for Git commands, then copy-pasting answers, witho…

兩個隊列實現一個棧思路c語言,兩個棧實現隊列功能C語言實現能運行!

#include#includetypedef struct sq{char *ps;int top;int Maxsize;}stack;void initstack(stack *s,int ms){s->ps(char*)malloc(ms*sizeof(char));s->top-1;s->Maxsizems;};void push(stack *s,char val){if(s->tops->Maxsize-1){printf("棧已滿\n"…

基本入門程序編寫格式和注意事項

在安裝好JDK后聯系程序的基本寫法。1、先創建記事本&#xff0c;如果有超級記事本如:notepad、ultraedit、editplus等更好。重命名把記事本后面的后綴名改為.java 但是值得注意的是要看看自己創建的記事本文檔是否是隱藏后綴名的。要是有設置隱藏的就取消隱藏&#xff0c;以免混…

.dll文件存在但是不顯示_一招巧妙解決U盤內文件明明存在,打開U盤而內容卻不顯示的問題...

大家可能都遇到過這種情況&#xff0c;就是說U盤中明明有文件&#xff0c;但是插在電腦上就是什么文件都沒有&#xff0c;一片空白&#xff0c;這樣的問題對于那些對文件很重要且僅保存了1份的人來說是很.kongbu.&#xff0c;因為U盤中的內容都是命根子。給大家介紹絕對有用的解…

《java入門第一季》之面向對象(包概述)

由于eclipse等ide的強大功能&#xff0c;使得建包&#xff0c;導包用一些快捷鍵就能完成。這里對包的概念做稍微的敘述&#xff0c;了解即可&#xff1a; 分包后使得項目更加清晰&#xff0c;提高代碼維護性。 包&#xff1a; A:其實就是文件夾 B:作用 …

Vue 框架-05-動態綁定 css 樣式

Vue 框架-05-動態綁定 css 樣式 今天的小實例是關于 Vue 框架動態綁定 css 樣式&#xff0c;這也是非常常用的一個部分 首先說一下 動態綁定&#xff0c;相對的大家都知道靜態綁定&#xff0c;靜態綁定的話&#xff0c;直接加 class“”就可以了&#xff0c;使用 Vue 呢之前也介…

ember.js_如何設置基本的Ember.js應用

ember.jsby Tracy Lee | ladyleet特雷西李(Tracy Lee)| Ladyleet 如何設置基本的Ember.js應用 (How to set up a Basic Ember.js app) So, you want to test out Ember, eh? This article will walk through building a basic app.所以&#xff0c;您想測試Ember&#xff0c;…

分數轉小數C語言,這是把小數轉換成分數的程序,可是輸入0.6666無限循環

該樓層疑似違規已被系統折疊 隱藏此樓查看此樓#include int main(){double a;scanf("%lf", &a);輸入小數int b, c 0, d 0;double b1 a;do{b1 *10;b (int)b1;printf("%d\n", b);if(b%10!0){c;if(d>0){c d;d 0;}}else{d;}}while(d<5);printf("…

arm處理器的歷史及現狀

1 arm處理器的發展歷史 arm1 arm2 arm3 arm6 arm7 arm9 arm11 arm cortex 2 arm處理器現狀 arm cortex A a即application&#xff0c;即應用處理器&#xff0c;主要用在智能手機、平板電腦和服務器上。 arm cortex M m即mcu&#xff0c;即單片機上的處理器&#xff0c;它的特點…

Linq常用List操作總結,ForEach、分頁、交并集、去重、SelectMany等

1 /*2 以下圍繞Person類實現&#xff0c;Person類只有Name和Age兩個屬性3 一.List<T>排序4 1.1 List<T>提供了很多排序方法&#xff0c;sort(),Orderby(),OrderByDescending().5 */6 7 lstPerson lstPerson.OrderByDescending(x>x.Name).ToList(); //降序8 ls…