Content categories - Developer guides 编辑

Every HTML element is a member of one or more content categories — these categories group elements that share common characteristics. This is a loose grouping (it doesn't actually create a relationship among elements of these categories), but they help define and describe the categories' shared behavior and their associated rules, especially when you come upon their intricate details. It's also possible for elements to not be a member of any of these categories.

There are three types of content categories:

  • Main content categories, which describe common rules shared by many elements.
  • Form-related content categories, which describe rules common to form-related elements.
  • Specific content categories, which describe rare categories shared only by a few elements, sometimes only in a specific context.

Note: A more detailed discussion of these content categories and their comparative functionalities is beyond the scope of this article; for that, you may wish to read the relevant portions of the HTML specification.

A Venn diagram showing how the various content categories interrelate. The following sections explain these relationships in text.

Main content categories

Metadata content

Elements belonging to the metadata content category modify the presentation or the behavior of the rest of the document, set up links to other documents, or convey other out of band information.

Elements belonging to this category are <base>, This is an obsolete API and is no longer guaranteed to work.<command>, <link>, <meta>, <noscript>, <script>, <style> and <title>.

Flow content

Elements belonging to the flow content category typically contain text or embedded content. They are: <a>, <abbr>, <address>, <article>, <aside>, <audio>, <b>,<bdo>, <bdi>, <blockquote>, <br>, <button>, <canvas>, <cite>, <code>, This is an obsolete API and is no longer guaranteed to work.<command>, <data>, <datalist>, <del>, <details>, <dfn>, <div>, <dl>, <em>, <embed>, <fieldset>, <figure>, <footer>, <form>, <h1>, <h2>, <h3>, <h4>, <h5>, <h6>, <header>, <hgroup>, <hr>, <i>, <iframe>, <img>, <input>, <ins>, <kbd>, This deprecated API should no longer be used, but will probably still work.<keygen>, <label>, <main>, <map>, <mark>, <math>, <menu>, <meter>, <nav>, <noscript>, <object>, <ol>, <output>, <p>, <picture>, <pre>, <progress>, <q>, <ruby>, <s>, <samp>, <script>, <section>, <select>, <small>, <span>, <strong>, <sub>, <sup>, <svg>, <table>, <template>, <textarea>, <time>, <ul>, <var>, <video>, <wbr> and Text.

A few other elements belong to this category, but only if a specific condition is fulfilled:

Sectioning content

Elements belonging to the sectioning content model create a section in the current outline that defines the scope of <header> elements, <footer> elements, and heading content.

Elements belonging to this category are <article>, <aside>, <nav> and <section>.

Do not confuse this content model with the sectioning root category, which isolates its content from the regular outline.

Heading content

Heading content defines the title of a section, whether marked by an explicit sectioning content element, or implicitly defined by the heading content itself.

Elements belonging to this category are <h1>, <h2>, <h3>, <h4>, <h5>, <h6> and <hgroup>.

Though likely to contain heading content, the <header> is not heading content itself.

Note: The <hgroup> element was removed from the W3C HTML specification prior to HTML 5 being finalized, but is still part of the WHATWG specification and is at least partially supported by most browsers.

Phrasing content

Phrasing content defines the text and the mark-up it contains. Runs of phrasing content make up paragraphs.

Elements belonging to this category are <abbr>, <audio>, <b>, <bdo>, <br>, <button>, <canvas>, <cite>, <code>, This is an obsolete API and is no longer guaranteed to work.<command>, <data>, <datalist>, <dfn>, <em>, <embed>, <i>, <iframe>, <img>, <input>, <kbd>, This deprecated API should no longer be used, but will probably still work.<keygen>, <label>, <mark>, <math>, <meter>, <noscript>, <object>, <output>, <picture>, <progress>, <q>, <ruby>, <samp>, <script>, <select>, <small>, <span>, <strong>, <sub>, <sup>, <svg>, <textarea>, <time>, <var>, <video>, <wbr> and plain text (not only consisting of white spaces characters).

A few other elements belong to this category, but only if a specific condition is fulfilled:

  • <a>, if it contains only phrasing content
  • <area>, if it is a descendant of a <map> element
  • <del>, if it contains only phrasing content
  • <ins>, if it contains only phrasing content
  • <link>, if the itemprop attribute is present
  • <map>, if it contains only phrasing content
  • <meta>, if the itemprop attribute is present

Embedded content

Embedded content imports another resource or inserts content from another mark-up language or namespace into the document. Elements that belong to this category include: <audio>, <canvas>, <embed>, <iframe>, <img>, <math>, <object>, <picture><svg>, <video>.

Interactive content

Interactive content includes elements that are specifically designed for user interaction. Elements that belong to this category include: <a>, <button>, <details>, <embed>, <iframe>, This deprecated API should no longer be used, but will probably still work.<keygen>, <label>, <select>, and <textarea>.
Some elements belong to this category only under specific conditions:

Palpable content

Content is palpable when it's neither empty or hidden; it is content that is rendered and is substantive. Elements whose model is flow content or phrasing content should have at least one node which is palpable.

Form-associated content

Form-associated content comprises elements that have a form owner, exposed by a form attribute. A form owner is either the containing <form> element or the element whose id is specified in the form attribute.

This category contains several sub-categories:

listed
Elements that are listed in the form.elements and fieldset.elements IDL collections. Contains <button>, <fieldset>, <input>, This deprecated API should no longer be used, but will probably still work.<keygen>, <object>, <output>, <select>, and <textarea>.
labelable
Elements that can be associated with <label> elements. Contains <button>, <input>, This deprecated API should no longer be used, but will probably still work.<keygen>, <meter>, <output>, <progress>, <select>, and <textarea>.
submittable
Elements that can be used for constructing the form data set when the form is submitted. Contains <button>, <input>, This deprecated API should no longer be used, but will probably still work.<keygen>, <object>, <select>, and <textarea>.
resettable
Elements that can be affected when a form is reset. Contains <input>, This deprecated API should no longer be used, but will probably still work.<keygen>, <output>,<select>, and <textarea>.

Secondary categories

There are some secondary classifications of elements that can be useful to be aware of as well.

Script-supporting elements

Script-supporting elements are elements which don't directly contribute to the rendered output of a document. Instead, they serve to support scripts, either by containing or specifying script code directly, or by specifying data that will be used by scripts.

The script-supporting elements are:

Transparent content model

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

For example, the <del> and <ins> elements are transparent:

<p>We hold these truths to be <del><em>sacred &amp; undeniable</em></del> <ins>self-evident</ins>.</p>

If those elements were removed, this fragment would still be valid HTML (if not correct English).

<p>We hold these truths to be <em>sacred &amp; undeniable</em> self-evident.</p>

Other content models

Sectioning root.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:154 次

字数:40187

最后编辑:7 年前

编辑次数:0 次

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