HTML ( Hypertext Markup Language ) elements historically were categorized as either "block-level" elements or "inline-level" elements. Since this is a presentational characteristic it is nowadays specified by CSS in the 流式布局 . A Block-level element occupies the entire horizontal space of its parent element (container), and vertical space equal to the height of its contents, thereby creating a "block". In this article, we'll examine HTML block-level elements and how they differ from inline-level elements .

Browsers typically display the block-level element with a newline both before and after the element. You can visualize them as a stack of boxes.

A block-level element always starts on a new line and takes up the full width available (stretches out to the left and right as far as it can).

The following example demonstrates the block-level element's influence:

Block-level elements

HTML

<p>This paragraph is a block-level element; its background has been colored to display the paragraph's parent element.</p>
					

CSS

p { background-color: #8ABB55; }
					

用法

  • Block-level elements may appear only within a <body> 元素。

Block-level vs. inline

There are a couple of key differences between block-level elements and inline elements:

Content model

Generally, block-level elements may contain inline elements and (sometimes) other block-level elements. Inherent in this structural distinction is the idea that block elements create "larger" structures than inline elements.

Default formatting

By default, block-level elements begin on new lines, but inline elements can start anywhere in a line.

The distinction of block-level vs. inline elements was used in HTML specifications up to 4.01. In HTML5, this binary distinction is replaced with a more complex set of content categories . While the "inline" category roughly corresponds to the category of 措词内容 , the "block-level" category doesn't directly correspond to any HTML5 content category, but "block-level" and "inline" elements combined together correspond to the flow content in HTML5. There are also additional categories, e.g. interactive content .

Elements

The following is a complete list of all HTML "block-level" elements (although "block-level" is not technically defined for elements that are new in HTML5).

<address>

Contact information.

<article>

Article content.

<aside>

Aside content.

<blockquote>

Long ("block") quotation.

<details>

Disclosure widget.

<dialog>

Dialog box.

<dd>

Describes a term in a description list.

<div>

Document division.

<dl>

Description list.

<dt>

Description list term.

<fieldset>

Field set label.

<figcaption>

Figure caption.

<figure>
Groups media content with a caption (see <figcaption> ).
<footer>

Section or page footer.

<form>

Input form.

<h1> , <h2> , <h3> , <h4> , <h5> , <h6>

Heading levels 1-6.

<header>

Section or page header.

<hgroup>

Groups header information.

<hr>

Horizontal rule (dividing line).

<li>

List item.

<main>

Contains the central content unique to this document.

<nav>

Contains navigation links.

<ol>

Ordered list.

<p>

Paragraph.

<pre>

Preformatted text.

<section>

Section of a web page.

<table>

Table.

<ul>

Unordered list.

另请参阅

元数据

  • 最后修改:
  1. Allowing cross-origin use of images and canvas
  2. 使用 CSS 将颜色应用到 HTML 元素
  3. Block-level elements
  4. DASH Adaptive Streaming for HTML 5 Video
  5. 用于 HTML 的日期和时间格式
  6. 全局属性
    1. 全局属性
    2. accesskey
    3. autocapitalize
    4. class
    5. contenteditable
    6. contextmenu
    7. data-*
    8. dir
    9. draggable
    10. dropzone
    11. hidden
    12. id
    13. inputmode
    14. is
    15. itemid
    16. itemprop
    17. itemref
    18. itemscope
    19. itemtype
    20. lang
    21. part
    22. slot
    23. spellcheck
    24. style
    25. tabindex
    26. title
    27. translate
    28. x-ms-acceleratorkey
    29. x-ms-format-detection
  7. HTML 属性参考
    1. HTML 属性参考
    2. HTML attribute: accept
    3. HTML attribute: capture
    4. HTML attribute: crossorigin
    5. HTML attribute: max
    6. HTML attribute: maxlength
    7. HTML attribute: min
    8. HTML attribute: minlength
    9. HTML attribute: multiple
    10. HTML attribute: pattern
    11. HTML attribute: readonly
    12. HTML attribute: rel
    13. HTML attribute: required
    14. HTML attribute: size
    15. HTML attribute: step
    16. The HTML autocomplete attribute
    17. 被禁用
  8. HTML documentation index
  9. HTML 元素参考
    1. HTML 元素参考
    2. <a>: The Anchor element
    3. <abbr>: The Abbreviation element
    4. <acronym>
    5. <address>: The Contact Address element
    6. <applet>: The Embed Java Applet element
    7. <area>
    8. <article>: The Article Contents element
    9. <aside>: The Aside element
    10. <audio>: The Embed Audio element
    11. <b>: The Bring Attention To element
    12. <base>: The Document Base URL element
    13. <basefont>
    14. <bdi>: The Bidirectional Isolate element
    15. <bdo>: The Bidirectional Text Override element
    16. <bgsound>: The Background Sound element (obsolete)
    17. <big>: The Bigger Text element
    18. <blink>: The Blinking Text element (obsolete)
    19. <blockquote>: The Block Quotation element
    20. <body>: The Document Body element
    21. <br>: The Line Break element
    22. <button>: The Button element
    23. <canvas>: The Graphics Canvas element
    24. <caption>: The Table Caption element
    25. <center>: The Centered Text element (obsolete)
    26. <cite>: The Citation element
    27. <code>: The Inline Code element
    28. <col>
    29. <colgroup>
    30. <command>: The HTML Command element
    31. <content>: The Shadow DOM Content Placeholder element (obsolete)
    32. <data>
    33. <datalist>: The HTML Data List element
    34. <dd>: The Description Details element
    35. <del>: The Deleted Text element
    36. <details>: The Details disclosure element
    37. <dfn>: The Definition element
    38. <dialog>: The Dialog element
    39. <dir>: The Directory element (obsolete)
    40. <div>: The Content Division element
    41. <dl>: The Description List element
    42. <dt>: The Description Term element
    43. <element>: The Custom Element element (Obsolete)
    44. <em>: The Emphasis element
    45. <embed>: The Embed External Content element
    46. <fieldset>: The Field Set element
    47. <figcaption>: The Figure Caption element
    48. <figure>: The Figure with Optional Caption element
    49. <font>
    50. <footer>
    51. <form>
    52. <frame>
    53. <frameset>
    54. <h1>–<h6>: The HTML Section Heading elements
    55. <head>: The Document Metadata (Header) element
    56. <header>
    57. <hgroup>
    58. <hr>: The Thematic Break (Horizontal Rule) element
    59. <html>: The HTML Document / Root element
    60. <i>: The Idiomatic Text element
    61. <iframe>: The Inline Frame element
    62. <image>: The obsolete Image element
    63. <img>: The Image Embed element
    64. <input>: The Input (Form Input) element
    65. <ins>
    66. <isindex>
    67. <kbd>: The Keyboard Input element
    68. <keygen>
    69. <label>
    70. <legend>
    71. <li>
    72. <link>: The External Resource Link element
    73. <listing>
    74. <main>
    75. <map>
    76. <mark>: The Mark Text element
    77. <marquee>: The Marquee element (Obsolete)
    78. <menu>
    79. <menuitem>
    80. <meta>: The Document-level Metadata element
    81. <meter>: The HTML Meter element
    82. <multicol>: The HTML Multi-Column Layout element (Obsolete)
    83. <nav>: The Navigation Section element
    84. <nextid>: The NeXT ID element (Obsolete)
    85. <nobr>: The Non-Breaking Text element (obsolete)
    86. <noembed>: The Embed Fallback element (Obsolete)
    87. <noframes>: The Frame Fallback element
    88. <noscript>
    89. <object>
    90. <ol>: The Ordered List element
    91. <optgroup>
    92. <option>: The HTML Option element
    93. <output>: The Output element
    94. <p>: The Paragraph element
    95. <param>: The Object Parameter element
    96. <picture>: The Picture element
    97. <plaintext>: The Plain Text element (Deprecated)
    98. <pre>: The Preformatted Text element
    99. <progress>: The Progress Indicator element
    100. <q>: The Inline Quotation element
    101. <rb>: The Ruby Base element
    102. <rp>: The Ruby Fallback Parenthesis element
    103. <rt>: The Ruby Text element
    104. <rtc>: The Ruby Text Container element
    105. <ruby>
    106. <s>
    107. <samp>: The Sample Output element
    108. <script>: The Script element
    109. <section>: The Generic Section element
    110. <select>: The HTML Select element
    111. <shadow>: The obsolete Shadow Root element
    112. <slot>
    113. <small>: the side comment element
    114. <source>: The Media or Image Source element
    115. <spacer>
    116. <span>
    117. <strike>
    118. <strong>: The Strong Importance element
    119. <style>: The Style Information element
    120. <sub>: The Subscript element
    121. <summary>: The Disclosure Summary element
    122. <sup>: The Superscript element
    123. <table>: The Table element
    124. <tbody>: The Table Body element
    125. <td>: The Table Data Cell element
    126. <template>: The Content Template element
    127. <textarea>
    128. <tfoot>: The Table Foot element
    129. <th>
    130. <thead>: The Table Head element
    131. <time>
    132. <title>: The Document Title element
    133. <tr>: The Table Row element
    134. <track>: The Embed Text Track element
    135. <tt>: The Teletype Text element (obsolete)
    136. <u>: The Unarticulated Annotation (Underline) element
    137. <ul>: The Unordered List element
    138. <var>: The Variable element
    139. <video>: The Video Embed element
    140. <wbr>
    141. <xmp>
  10. HTML 参考
  11. 内联元素
  12. Link 类型
    1. Link 类型
    2. Link types: dns-prefetch
    3. Link types: manifest
    4. Link types: modulepreload
    5. Link types: noopener
    6. Link types: noreferrer
    7. Link types: preconnect
    8. Link types: prefetch
    9. Link types: preload
    10. Link types: prerender
  13. Microdata
  14. Microformats
  15. 采用 rel="preload" 预加载内容
  16. Quirks Mode and Standards Mode
  17. Using the application cache