集团`dt`和`dd`在``下dl` span` [英] Group `dt` and `dd` in `span` under `dl`
问题描述
我试图显示或内隐藏某些
。这是有效的HTML?如果浏览器抱怨这还是合法?我看了看 DT
/ DD
组DL DL
规格,但找不到任何东西说, DL
可以包含其他的东西比 DT
和 DD
的孩子。我需要做的这是我使用 angularJS
提供添加或删除从 DOM元素的这种简洁的方式
< DL>
< DT>条款< / DT>
< DD>定义< / DD> <跨度NG-IF =真正的>
< DT>期限2'; / DT>
< DD>定义2'; / DD>
< / SPAN>
< / DL>
这是无效的HTML5,因为的 DL
元素是
零个或多个组,每组由一个或多个
DT
元素
后面跟着一个或多个DD
元素,任选与混合
脚本的支持元素的。
块引用>所以
DL
不能包含跨度
,但大多数浏览器将呈现正确的。而不是
跨度
,我建议使用的迪
元素。它们是无效的HTML5了,但是在XHTML 2是有效的。< DL>
< DT>条款< / DT>
< DD>定义< / DD>
<二NG-IF =真正的>
< DT>期限2'; / DT>
< DD>定义2'; / DD>
< / DI>
< / DL>不过,缺点是,旧的IE浏览器将无法识别
迪
,所以除非你使用文件也不会CSS样式适用于他们.createElement(DI),该文件加载时
。I'm trying to show or hide certain
dt
/dd
groups within adl
. Is this valid HTML? Should browsers complain about this or is it legit? I've looked at thedl
specs but couldn't find anything saying that thedl
can contain something other thandt
anddd
children. I need to do this as I'm usingangularJS
which provides this neat way of adding or removing elements from theDOM
<dl> <dt>Term</dt> <dd>Definition</dd> <span ng-if="true"> <dt>Term 2</dt> <dd>Definition 2</dd> </span> </dl>
解决方案This is not valid HTML5, because the content model of
dl
elements isZero or more groups each consisting of one or more
dt
elements followed by one or moredd
elements, optionally intermixed with script-supporting elements.So
dl
can't containspan
, but most browsers will render it correctly.Instead of
span
, I suggest usingdi
elements. They are invalid HTML5 too, but were valid in XHTML2.<dl> <dt>Term</dt> <dd>Definition</dd> <di ng-if="true"> <dt>Term 2</dt> <dd>Definition 2</dd> </di> </dl>
However, the downside is that old IE won't recognize
di
, so it won't apply CSS styles to them unless you usedocument.createElement('di')
while the document is loading.这篇关于集团`dt`和`dd`在``下dl` span`的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!