Can I put anything inside DL/DT/DDs?

2020-02-20 09:04发布

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

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

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

Do any browsers, or search engines complain?

2条回答
冷血范
2楼-- · 2020-02-20 09:23

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.

查看更多
Melony?
3楼-- · 2020-02-20 09:25

Updated answer based on comments:

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

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

Original answer:

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

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.

Source: W3C

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

查看更多
登录 后发表回答