CSS 或 HTML 规范中是否定义了块元素和内联元素?
Are block and inline elements defined in the CSS or HTML spec?
我会说元素的显示是 CSS 的事情。但是,在很多地方,我读到 HTML div is a block element
之类的东西。它只是人们使用的快捷方式吗?
它实际上是在 CSS 规范中指定的(例如 div
是块元素)还是它只是浏览器使用的一般约定?它在规范中的什么位置?
它是在 HTML 规范中定义的,但现在有点宽
The distinction of block-level vs. inline elements is used in HTML specifications up to 4.01. In HTML5, this binary distinction is replaced with a more complex set of content categories. The "block-level" category roughly corresponds to the category of flow content in HTML5, while "inline" corresponds to phrasing content, but there are additional categories.
更多信息:https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements
html5 规范在描述这些元素时不谈论 inline
和 block
元素,他们谈论:
Content-Model: Kinds of Content
- 元数据内容
- 流内容
- 分段内容
- 标题内容
- 措辞内容
- 嵌入内容
- 互动内容
HTML4 使用了 inline
和 block-level
但是:
HTML does not use the terms "block-level" or "inline" as part of its content model rules, to reduce confusion with CSS.
w3c 在 10 Rendering 浏览器应如何呈现元素中提出了建议,但是:
User agents are not required to present HTML documents in any particular way. However, this section provides a set of suggestions for rendering HTML documents that, if followed, are likely to lead to a user experience that closely resembles the experience intended by the documents' authors.
因此 content-model 定义哪些元素可以出现在哪些位置,但仅建议应如何呈现它们。然而 display
值,如 block
、inline
、table
、...在所有浏览器中几乎都是相等的,但是 padding
、margin
, ...可能会有所不同。
对于 html4 Appendix D. Default style sheet for HTML 4 存在:
This style sheet describes the typical formatting of all HTML 4 ([HTML4]) elements based on extensive research into current UA practice. Developers are encouraged to use it as a default style sheet in their implementations.
Html 与渲染无关,html 是一种允许以标准化方式组织信息的标记语言。如果浏览器能够根据规范处理 html,则浏览器符合 html 规范。除了视觉呈现的 CSS 规范之外,如果浏览器根据这些规范呈现 DOM 元素,则浏览器符合这些规范。如果浏览器符合所有这些单独的标准,那么它就符合网络标准s。
HTML 3.2 defined the terms.
CSS 在定义 the display
property but this expanded to support many more values 时部分采用了它们。
HTML4规范continued to use the terms.
HTML 5 删除了术语块和内联以支持 a wider set of categories。
我会说元素的显示是 CSS 的事情。但是,在很多地方,我读到 HTML div is a block element
之类的东西。它只是人们使用的快捷方式吗?
它实际上是在 CSS 规范中指定的(例如 div
是块元素)还是它只是浏览器使用的一般约定?它在规范中的什么位置?
它是在 HTML 规范中定义的,但现在有点宽
The distinction of block-level vs. inline elements is used in HTML specifications up to 4.01. In HTML5, this binary distinction is replaced with a more complex set of content categories. The "block-level" category roughly corresponds to the category of flow content in HTML5, while "inline" corresponds to phrasing content, but there are additional categories.
更多信息:https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements
html5 规范在描述这些元素时不谈论 inline
和 block
元素,他们谈论:
Content-Model: Kinds of Content
- 元数据内容
- 流内容
- 分段内容
- 标题内容
- 措辞内容
- 嵌入内容
- 互动内容
HTML4 使用了 inline
和 block-level
但是:
HTML does not use the terms "block-level" or "inline" as part of its content model rules, to reduce confusion with CSS.
w3c 在 10 Rendering 浏览器应如何呈现元素中提出了建议,但是:
User agents are not required to present HTML documents in any particular way. However, this section provides a set of suggestions for rendering HTML documents that, if followed, are likely to lead to a user experience that closely resembles the experience intended by the documents' authors.
因此 content-model 定义哪些元素可以出现在哪些位置,但仅建议应如何呈现它们。然而 display
值,如 block
、inline
、table
、...在所有浏览器中几乎都是相等的,但是 padding
、margin
, ...可能会有所不同。
对于 html4 Appendix D. Default style sheet for HTML 4 存在:
This style sheet describes the typical formatting of all HTML 4 ([HTML4]) elements based on extensive research into current UA practice. Developers are encouraged to use it as a default style sheet in their implementations.
Html 与渲染无关,html 是一种允许以标准化方式组织信息的标记语言。如果浏览器能够根据规范处理 html,则浏览器符合 html 规范。除了视觉呈现的 CSS 规范之外,如果浏览器根据这些规范呈现 DOM 元素,则浏览器符合这些规范。如果浏览器符合所有这些单独的标准,那么它就符合网络标准s。
HTML 3.2 defined the terms.
CSS 在定义 the display
property but this expanded to support many more values 时部分采用了它们。
HTML4规范continued to use the terms.
HTML 5 删除了术语块和内联以支持 a wider set of categories。