dd
元素可以包含 ul
元素吗?像这样:
<dl>
<dt>Lorem</dt>
<dd>Sed lectus</dd>
<dt>Vestibulum</dt>
<dd>
<ul>
<li>viverra nec</li>
<li>blandit vel</li>
<li>egestas et</li>
</ul>
</dd>
<dt>Suspendisse</dt>
<dd>Nulla quam</dd>
</dl>
最佳答案
是的,它对 <dd>
有效包含 <ul>
.根据HTML Spec , <dd>
元素应包含 flow content .无序列表被视为流内容。
但是,如果您示例中的每个项目都是程序的替代描述 <dt>
术语,它们不应在无序列表中标记,而应使用一系列 <dd>
标记元素。
例如,以下是有效的 HTML,但语义不正确——因为它暗示整个列表是对该术语的单数描述。
<dl>
<dt>Firefox</dt>
<dd>
<ul>
<li>A free, open source, cross-platform, graphical web browser developed by the Mozilla Corporation and hundreds of volunteers.</li>
<li>The Red Panda also known as the Lesser Panda, Wah, Bear Cat or Firefox, is a mostly herbivorous mammal, slightly larger than a domestic cat (60 cm long).</li>
</ul>
</dd>
</dl>
标记此内容的有效和语义正确方法是:
<dl>
<dt>Firefox</dt>
<dd>A free, open source, cross-platform, graphical web browser developed by the Mozilla Corporation and hundreds of volunteers.</dd>
<dd>The Red Panda also known as the Lesser Panda, Wah, Bear Cat or Firefox, is a mostly herbivorous mammal, slightly larger than a domestic cat (60 cm long).</dd>
</dl>
关于html - 描述细节元素中是否允许无序列表元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60876426/