The DOA (or more appropriately, Dead Before Arrival) XHTML2 working standard indicates support for the <di>
tag.
DOA(或更合适的是,Dead Before Arrival)XHTML2工作标准表示支持
[...] The term and its definition can be grouped within a
di
element to help clarify the relationship between a term and its definition(s).[...]该术语及其定义可以在di元素中分组,以帮助阐明术语与其定义之间的关系。
To clarify, this tag would be used to group <dt>
and <dd>
tags together under a <dl>
:
为了澄清,此标记将用于在
-
下将
- 和
- 标记组合在一起:
<dl>
<di>
<dt>defenestrate</dt>
<dd>throw through or out of the window; "XHTML2 was defenestrated"</dd>
<dd>what I will do if web standards keep going they way they are</dd>
</di>
</dl>
Anyway, since <di>
is out the window (heh), I was wondering what (if any) currently supported markup patterns could be described as semantically and structurally equivalent? I've essentially accepted that <dl>
is not sufficient for my requirements (as far as aesthetic requirements go), so I'm on to looking at other solutions.
无论如何,由于
-
不足以满足我的要求(就美学要求而言),所以我正在寻找其他解决方案。
My intent for <di>
was primarily a style hook1, as I'm using a definition list and intend to style the term/definition groupings as a single item.
我对
For the sake of accessibility, I will be using the aria-*
and role
attributes to help define the relationship, but I'm hoping that there exists some generally accepted structure to emulate <di>
, that I simply haven't encountered.
为了便于访问,我将使用aria- *和role属性来帮助定义关系,但我希望有一些普遍接受的结构来模拟
For example, I'm considering something like the following:
例如,我正在考虑以下内容:
<ul>
<li>
<dfn id="term-1">term</dfn>
<p aria-labelledby="term-1">definition for term 1</p>
<p aria-labelledby="term-1">another definition for term 1</p>
</li>
<li>
<dfn id="term-2">term</dfn>
<p aria-labelledby="term-2">definition for term 2</p>
<p aria-labelledby="term-2">another definition for term 2</p>
</li>
</ul>
1. As I understand it, this is an oft-cited reason for its exclusion from HTML5 (that it is merely a style hook). Frankly, I think that's bull since it is a perfectly reasonable way to group terms and definitions for both aesthetic and parsing purposes. But who cares, right? Unquoted attributes and incomplete tags are far more important.</sarcasm>
1.据我了解,这是一个经常被引用的原因,它被排除在HTML5之外(它只是一个样式钩子)。坦率地说,我认为这是公牛,因为它是一种完美合理的方式,可以为美学和解析目的分组术语和定义。但谁在乎呢,对吧?不带引号的属性和不完整的标签更为重要。
1 个解决方案
#1
4
HTML5 CR defines a grouping within a dl
element, so that e.g. a dd
element followed by one or more dd
elements constitutes a group, the next dd
starts a new group etc. In this sense, the di
element would be structurally redundant. On the other hand, a dl
element has really no semantics (beyond being structurally something), and there is no known software that processes it in any particular way, beyond default rendering issues.
HTML5 CR定义了dl元素中的分组,因此例如dd元素后跟一个或多个dd元素构成一个组,下一个dd开始一个新组等。在这个意义上,di元素在结构上是多余的。另一方面,dl元素实际上没有语义(除了在结构上是某种东西),并且没有已知的软件以任何特定的方式处理它,超出了默认的渲染问题。
If you wish to style such a group as a unit, you are mostly out of luck, as per specs and drafts. There is no proposal being considered about adding anything like di
. You might submit a proposal, referring to tbody
and optgroup
as precedents (i.e. as special-purpose grouping elements within specific elements), but that would be a long way.
如果你希望将这样一个团体作为一个单元进行设计,那么根据规格和草稿,你大多都不走运。没有考虑添加像di这样的东西。您可以提交一个提案,将tbody和optgroup称为先例(即作为特定元素中的特殊用途分组元素),但这将是一个漫长的过程。
A short way is to use div
for grouping inside dl
. Of course it’s “invalid”, but that’s just a formal position, and browsers don’t really care. They seem to digest this fine:
一个简短的方法是使用div在dl内进行分组。当然它是“无效的”,但这只是一个正式的位置,浏览器并不真正关心。他们似乎消化了这个罚款:
<dl>
<div>
<dt>defenestrate</dt>
<dd>throw through or out of the window; "XHTML2 was defenestrated"</dd>
<dd>what I will do if web standards keep going they way they are</dd>
</div>
<div>
<dt>pragmatic HTML</dt>
<dd>using markup according to how things actually work in browsers
and other relevant software</dd>
</div>
</dl>
Browsers parse this so that div
elements are children of the dl
element, and the dt
and dd
elements still have their normal effect on default formatting.
浏览器解析这个,以便div元素是dl元素的子元素,而dt和dd元素仍然对默认格式有正常的影响。
And now you can style the units, e.g.
现在你可以设置单位的样式,例如
<style>
dl > div { border: solid red 1px; margin-bottom: 0.6em; }
</style>
You may get flamed for this. A safer, duller approach is to make each unit a separate dl
element (and wrap the dl
elements in a div
container if you need to deal with the all of them as a single element).
你可能会因此受到抨击。更安全,更无聊的方法是使每个单元成为单独的dl元素(如果需要将所有单元作为单个元素处理,则将dl元素包装在div容器中)。
#1
4
HTML5 CR defines a grouping within a dl
element, so that e.g. a dd
element followed by one or more dd
elements constitutes a group, the next dd
starts a new group etc. In this sense, the di
element would be structurally redundant. On the other hand, a dl
element has really no semantics (beyond being structurally something), and there is no known software that processes it in any particular way, beyond default rendering issues.
HTML5 CR定义了dl元素中的分组,因此例如dd元素后跟一个或多个dd元素构成一个组,下一个dd开始一个新组等。在这个意义上,di元素在结构上是多余的。另一方面,dl元素实际上没有语义(除了在结构上是某种东西),并且没有已知的软件以任何特定的方式处理它,超出了默认的渲染问题。
If you wish to style such a group as a unit, you are mostly out of luck, as per specs and drafts. There is no proposal being considered about adding anything like di
. You might submit a proposal, referring to tbody
and optgroup
as precedents (i.e. as special-purpose grouping elements within specific elements), but that would be a long way.
如果你希望将这样一个团体作为一个单元进行设计,那么根据规格和草稿,你大多都不走运。没有考虑添加像di这样的东西。您可以提交一个提案,将tbody和optgroup称为先例(即作为特定元素中的特殊用途分组元素),但这将是一个漫长的过程。
A short way is to use div
for grouping inside dl
. Of course it’s “invalid”, but that’s just a formal position, and browsers don’t really care. They seem to digest this fine:
一个简短的方法是使用div在dl内进行分组。当然它是“无效的”,但这只是一个正式的位置,浏览器并不真正关心。他们似乎消化了这个罚款:
<dl>
<div>
<dt>defenestrate</dt>
<dd>throw through or out of the window; "XHTML2 was defenestrated"</dd>
<dd>what I will do if web standards keep going they way they are</dd>
</div>
<div>
<dt>pragmatic HTML</dt>
<dd>using markup according to how things actually work in browsers
and other relevant software</dd>
</div>
</dl>
Browsers parse this so that div
elements are children of the dl
element, and the dt
and dd
elements still have their normal effect on default formatting.
浏览器解析这个,以便div元素是dl元素的子元素,而dt和dd元素仍然对默认格式有正常的影响。
And now you can style the units, e.g.
现在你可以设置单位的样式,例如
<style>
dl > div { border: solid red 1px; margin-bottom: 0.6em; }
</style>
You may get flamed for this. A safer, duller approach is to make each unit a separate dl
element (and wrap the dl
elements in a div
container if you need to deal with the all of them as a single element).
你可能会因此受到抨击。更安全,更无聊的方法是使每个单元成为单独的dl元素(如果需要将所有单元作为单个元素处理,则将dl元素包装在div容器中)。