适当使用DL和DD吗?

发布于 2024-07-09 03:13:50 字数 255 浏览 11 评论 0原文

我最近有一些为我设计的网站模板。 我得到了最终的 HTML 代码,该代码已验证,但文档的结构是使用 DL-DD 对进行布局的:

<dl>
  <dd class="some-class">
    Some text.
  </dd>
</dl>

我对这些标签不是特别熟悉,因为我从未经常使用它们,但它们似乎并不是有意的用于文档结构。 我对吗? 设计师为什么要这么做?

I had some site templates designed for me recently. I got the final HTML code, which validates, but the structure of the document is laid out using DL-DD pairs:

<dl>
  <dd class="some-class">
    Some text.
  </dd>
</dl>

I'm not especially familiar with those tags as I've never used them much, but they don't seem intended for document structure. Am I right? Why would a designer do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

思慕 2024-07-16 03:13:51

来自 WC3:http://www.w3.org/TR /html401/struct/lists.html#h-10.3

定义列表与其他类型的列表仅略有不同,因为列表项由两部分组成:术语和描述。 该术语由 DT 元素给出,并且仅限于内联内容。 使用包含块级内容的 DD 元素给出描述。

因此,根据您的示例,这些类型的结构应用于特定类型的内容,而不是构建不适合此上下文的数据。

From WC3: http://www.w3.org/TR/html401/struct/lists.html#h-10.3

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.

So given your example, these types of structures should be used for a specific type of content and not structuring of data that does not fit within this context.

吃颗糖壮壮胆 2024-07-16 03:13:51

你是对的,不应该这样使用它。 我能想到的设计者使用它们的唯一原因是

标签在大多数浏览器中都是缩进的。 如果它们覆盖了它们的填充/边距,那么您的猜测和我的一样好。

You're right in that it shouldn't be used like that. The only reason I can think of for the designer using them is that the <dd> tag is indented in most browsers. If they're overriding the padding/margins on them, then your guess is as good as mine.

孤芳又自赏 2024-07-16 03:13:50

DL 标签与 UL 标签大致相同,它启动一个无序列表。

不同之处在于,DL/DD 对中基本上没有项目符号。

但大多数时候,它用于实际用途,即D定义列表,并与DTDD,即Definition Term和Definition Description,它们将看起来像 :

<DL>
  <DT>CSS</DT>
  <DD>Cascading Style Sheet</DD>
</DL>

默认情况下,该术语会缩进一点,并进一步缩进它的定义。

A DL tag is about the same as a UL tag, it starts an unordered list.

The difference being that there basically is no bullet in a DL/DD couple.

Most of the time, though, it's used for it's real use, that is, a Definition List, and is used with DT and DD, which are Definition Term and Definition Description which would look like :

<DL>
  <DT>CSS</DT>
  <DD>Cascading Style Sheet</DD>
</DL>

which will, by default, indent the term a bit, and indent it's definition a bit more.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文