gpt4 book ai didi

html - 哪些 HTML 元素可以归类为 "Transparent Content"?

转载 作者:行者123 更新时间:2023-12-05 06:54:03 24 4
gpt4 key购买 nike

具有透明内容模型的元素定义如下:

If an element has a transparent content model, then its contents mustbe structured such that they would be valid HTML 5, even if thetransparent element were removed and replaced by the child elements.

来源:https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#transparent_content_model

有了这个定义,并且知道规范定义的允许的元素内容类型,是否可以安全地说这些元素可以归类为“透明内容”?:

<a> , <article> , <aside> , <audio> , <b> , <blockquote> , <button> , <canvas> , <code> , <del> , <details> , <div> , <em> , <fieldset> , <figure> , <footer> , <form> , <h1> , <h2> , <h3> , <h4> , <h5> , <h6> , <header> , <i> , <ins> , <kbd> , <label> , <main> , <mark> , <meter> , <nav> , <p> , <picture> , <pre> , <progress> , <q> , <s> , <section> , <small> , <span> , <strong> , <sub> , <sup> , <textarea> , <u> , <video>

(是否存在更权威的列表?我找不到一个,因为透明内容的搜索结果很快就会与 CSS 相关。)


W3 规范: https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#transparent-content-models

WHATWG 规范: https://html.spec.whatwg.org/dev/dom.html#transparent-content-models

最佳答案

Elements with a Transparent content model are defined as follows: ...

您引用的 MDN 是引用,但不是官方规范。它是次要来源,这意味着它对于理解技术细节很有用,但不能依赖它来提供实际定义。

W3C 在 2019 年将 HTML5 规范的权威权让给了 WHATWG,因此 html.spec.whatwg.org是撰写本文时的规范规范。

规范包括 "Transparent content models" 的以下内容

Some elements are described as transparent; they have "transparent" in the description of their content model. The content model of a transparent element is derived from the content model of its parent element: the elements required in the part of the content model that is "transparent" are the same elements as required in the part of the content model of the parent of the transparent element in which the transparent element finds itself.

那么你的问题是:

With [an incorrect] definition, and knowing the permitted content types of elements as defined by the spec, would it be safe to say that these elements can be classified as "Transparent content"?

没有。该规范在第 4 节(“HTML 的元素”)中的相应“内容模型:”标题中指示了每个元素的内容模型。

虽然规范在 "3.2.5.2 Kinds of Content" 中包含了不同类型内容的便捷列表,遗憾的是没有透明内容列表。

因此,要确定哪些元素具有透明内容模型,您必须搜索所有 HTML 元素的列表。

为方便起见,目前具有透明内容模型的元素如下:

关于html - 哪些 HTML 元素可以归类为 "Transparent Content"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65638126/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com