描述细节元素中是否允许无序列表元素?
Is an unordered list element allowed inside a description details element?
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>
elements should contain 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>
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>
elements should contain 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>