使用 HTML 描述列表(dl、dt、dd)有什么好处?
What are the benefits of using HTML description lists (dl, dt, dd)?
MDN 解释了 <dl>
、<dt>
和 <dd>
标签可用于实现词汇表或 key-value 对列表。
根据 maxdesign.com.au(文章发表于 2004 年,其表述可能不准确),使用它们甚至有缺点:
- 定义列表中的
<dt>
不能包含块级元素;
- 搜索引擎不会索引他们为 heading-based 内容所做的定义列表内容 "in the same way";
- 它们不能包含屏幕 reader 辅助功能,例如“标签”和“headers”以将信息联系在一起。
此外,他们的基本 browser-out-of-the-box 样式可以轻松复制,同时忽略了上述缺点。
在表格、段落或任何其他元素上使用 HTML 描述列表是否有任何 有形的 好处(在语义、SEO 等方面) ?
- The
<dt>
within definition lists cannot contain block level elements;
Untrue - <dt>
s 可以包含一些块级元素,例如段落。
- Search engines will not index definition list content "in the same way" that they do for heading-based content;
那又怎样?不以同样的方式并不意味着更好或更坏。通常,在写得很好的页面标题中,应该得分高于定义术语或描述。
- They cannot contain screen reader accessibility features such as “labels” and “headers” to tie information together.
大部分是不真实的。 <dt>
不能包含 headers。 <dd>
可以。两者都可以包含标签(尽管想要在 <dt>
中包含一个标签会很奇怪)。
Are there any tangible benefits (in terms of semantics, SEO, etc.) of using HTML description lists over tables, paragraphs, or perhaps any other element?
<dt>
s 自动获得 "term" 角色供辅助工具使用。
<dd>
s 自动获得 "definition" 角色供辅助工具使用。
MDN 解释了 <dl>
、<dt>
和 <dd>
标签可用于实现词汇表或 key-value 对列表。
根据 maxdesign.com.au(文章发表于 2004 年,其表述可能不准确),使用它们甚至有缺点:
- 定义列表中的
<dt>
不能包含块级元素; - 搜索引擎不会索引他们为 heading-based 内容所做的定义列表内容 "in the same way";
- 它们不能包含屏幕 reader 辅助功能,例如“标签”和“headers”以将信息联系在一起。
此外,他们的基本 browser-out-of-the-box 样式可以轻松复制,同时忽略了上述缺点。
在表格、段落或任何其他元素上使用 HTML 描述列表是否有任何 有形的 好处(在语义、SEO 等方面) ?
- The
<dt>
within definition lists cannot contain block level elements;
Untrue - <dt>
s 可以包含一些块级元素,例如段落。
- Search engines will not index definition list content "in the same way" that they do for heading-based content;
那又怎样?不以同样的方式并不意味着更好或更坏。通常,在写得很好的页面标题中,应该得分高于定义术语或描述。
- They cannot contain screen reader accessibility features such as “labels” and “headers” to tie information together.
大部分是不真实的。 <dt>
不能包含 headers。 <dd>
可以。两者都可以包含标签(尽管想要在 <dt>
中包含一个标签会很奇怪)。
Are there any tangible benefits (in terms of semantics, SEO, etc.) of using HTML description lists over tables, paragraphs, or perhaps any other element?
<dt>
s 自动获得 "term" 角色供辅助工具使用。
<dd>
s 自动获得 "definition" 角色供辅助工具使用。