“嵌套”有正式的定义吗?

发布于 2024-11-07 13:18:42 字数 502 浏览 0 评论 0原文

在 HTML 中,嵌套到底意味着什么?是否有定义该术语的规范?

例如,一些消息来源指出,仅仅将任何元素放在另一个元素中就是嵌套:

<div>Thee is a span <span>nested</span> in this div</div>

其他消息来源说它们必须是同一类型的元素:

<span>There is a span <span>nested</span> in another span</span>

还有其他消息来源表明,仅当元素是唯一的直接子元素时才嵌套:

<span><span>nested</span></span>

是否有正式的定义,还是“嵌套”更像是一个随意的术语?与HTML的定义或规范有关吗?

In HTML, what does nesting mean exactly? Is there a specification which defines the term?

For example, some sources state that merely placing any element in another is nesting:

<div>Thee is a span <span>nested</span> in this div</div>

Other sources say that they must be elements of the same type:

<span>There is a span <span>nested</span> in another span</span>

Still other sources suggest that it is nested only if the elements is the only immediate child:

<span><span>nested</span></span>

Is there a formal definition, or is "nesting" more of a casual term? Is it related to the definition of HTML or the specifications?

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

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

发布评论

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

评论(2

昔梦 2024-11-14 13:18:42

HTML 元素可能的嵌套可以从规范中得出。

HTML 4(和 XHTML 1.0)中允许的元素嵌套这些版本的演示基于:

...过渡性 DTD,位于 1999 年 12 月 24 日版本的 HTML 4.01 规范中。

(无法找到更完整的更新内容。)

嵌套就是将元素置于其他元素内部的树状结构。例如,请参阅嵌套 HTML 标签嵌套,或 嵌套表(更直观的示例)。

不限制仅使用相同类型的标签(例如仅将嵌套视为将 div 放置在另一个 div 中)。据我所知,这是一个非常通用的术语。

The possible nesting of HTML elements can be derived from the specifications.

Allowed nesting of elements in HTML 4 (and XHTML 1.0) has a presentation for those versions based on:

... the transitional DTD, in the 1999-12-24 version of the HTML 4.01 Specification.

(Can't find something more recent that is as complete.)

Nesting is simply the way you put elements inside others, in a tree-like structure. See for instance Nesting HTML tags, Nesting, or Nesting Tables (more visual example).

There is no restriction to only the same type of tag (like only considering nesting as placing div in another div). It's a very generic term as far as I know.

余厌 2024-11-14 13:18:42

这是一个随意且上下文相关的术语。

一般来说,“嵌套 foos”的意思是“拥有一个 foo ,它是另一个 foo 的(不一定是直接)后代”。在不是嵌套特定事物的情况下,它通常仅意味着“在内部但在任何深度”

It is a casual and context sensitive term.

Generally, "Nested foos" means "Having a foo that is a (not necessarily direct) descendent of another foo". In a context where it isn't one specific thing being nested, it usually just means "inside but at any depth"

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