我可以在DL / DT / DD中放置任何东西吗?

时间:2022-11-14 20:12:42

can I use definition lists just like unordered/ordered lists?

我可以像无序/有序列表一样使用定义列表吗?

I mean insert DIVs any anything I want inside DT or DD?

我的意思是在DT或DD中插入任何我想要的东西?

<dl>
  <dt>
    ...
  </dt>
  <dd>
    ...
  </dd>
</dl>

Do any browsers, or search engines complain?

是否有任何浏览器或搜索引擎抱怨?

2 个解决方案

#1


20  

Updated answer based on comments:

根据评论更新了答案:

This was originally answered in 2011 for HTML 4, but the answer is different for HTML5:

这最初是在2011年针对HTML 4回答的,但HTML5的答案有所不同:

dt Flow content, but with no header, footer, sectioning content, or heading content descendants. dd Flow content.

dt流内容,但没有页眉,页脚,节内容或标题内容后代。 dd流量内容。

Original answer:

原始答案:

DT elements should contain inline content.
DD elements should contain block-level content.

DT元素应包含内联内容。 DD元素应包含块级内容。

Definition lists vary only slightly from other types of lists in that list items consist of two parts: a term and a description. The term is given by the DT element and is restricted to inline content. The description is given with a DD element that contains block-level content.

定义列表与其他类型的列表略有不同,列表项由两部分组成:术语和描述。该术语由DT元素给出,仅限于内联内容。使用包含块级内容的DD元素给出描述。

Source: W3C

资料来源:W3C

This question is also an interesting read: Why use definition lists (DL,DD,DT) tags for HTML forms instead of tables?

这个问题也是一个有趣的读物:为什么要使用HTML表单的定义列表(DL,DD,DT)标签而不是表格?

#2


9  

Inside a DL you can only put DT and DD tags. A DT tag is an inline tag, so you should not put block elements in it. A DD tag can contain basically anything you want, it's a flow content tag.

在DL内部,您只能放置DT和DD标签。 DT标记是内联标记,因此不应将块元素放入其中。 DD标签基本上可以包含您想要的任何内容,它是一个流内容标签。

#1


20  

Updated answer based on comments:

根据评论更新了答案:

This was originally answered in 2011 for HTML 4, but the answer is different for HTML5:

这最初是在2011年针对HTML 4回答的,但HTML5的答案有所不同:

dt Flow content, but with no header, footer, sectioning content, or heading content descendants. dd Flow content.

dt流内容,但没有页眉,页脚,节内容或标题内容后代。 dd流量内容。

Original answer:

原始答案:

DT elements should contain inline content.
DD elements should contain block-level content.

DT元素应包含内联内容。 DD元素应包含块级内容。

Definition lists vary only slightly from other types of lists in that list items consist of two parts: a term and a description. The term is given by the DT element and is restricted to inline content. The description is given with a DD element that contains block-level content.

定义列表与其他类型的列表略有不同,列表项由两部分组成:术语和描述。该术语由DT元素给出,仅限于内联内容。使用包含块级内容的DD元素给出描述。

Source: W3C

资料来源:W3C

This question is also an interesting read: Why use definition lists (DL,DD,DT) tags for HTML forms instead of tables?

这个问题也是一个有趣的读物:为什么要使用HTML表单的定义列表(DL,DD,DT)标签而不是表格?

#2


9  

Inside a DL you can only put DT and DD tags. A DT tag is an inline tag, so you should not put block elements in it. A DD tag can contain basically anything you want, it's a flow content tag.

在DL内部,您只能放置DT和DD标签。 DT标记是内联标记,因此不应将块元素放入其中。 DD标签基本上可以包含您想要的任何内容,它是一个流内容标签。