Блочные и строчные элементы. HTML - Строчные и блочные элементы

HTML (Hypertext Markup Language ) elements historically were categorized as either "block-level" elements or "inline" elements . By default, a block-level element occupies the entire space of its parent element (container), thereby creating a "block." This article helps to explain what this means.

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

This paragraph is a block-level element; its background has been colored to display the paragraph"s parent element.

CSS

p { background-color: #8ABB55; }

Usage

  • Block-level elements may appear only within a element.

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.

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).

Contact information. Article content. element represents a portion of a document whose content is only indirectly related to the document" s main content.> Aside content. Element (or HTML Block Quotation Element) indicates that the enclosed text is an extended quotation. Usually, this is rendered visually by indentation (see Notes for how to change it). A URL for the source of the quotation may be given using the cite attribute, while a text representation of the source can be given using the element.">

Long ("block") quotation.
Disclosure widget. element represents a dialog box or other interactive component, such as an inspector or window."> Dialog box. element provides the details about or the definition of the preceding term (
) in a description list (
).">
Describes a term in a description list. ) is the generic container for flow content. It has no effect on the content or layout until styled using CSS.">
Document division. element represents a description list. The element encloses a list of groups of terms (specified using the
element) and descriptions (provided by
elements). Common uses for this element are to implement a glossary or to display metadata (a list of key-value pairs).">
Description list. element specifies a term in a description or definition list, and as such must be used inside a
element.">
Description list term. element is used to group several controls as well as labels (