HTML-blokkelementer og inline-elementer

HTML-elementer kan kombineres ved hjælp af <div> og <span>.

HTML Block Element

Most HTML elements are defined as block-level elements or inline elements.

Editor's Note: 'Block-level element' is translated as 'block level element', and 'inline element' is translated as 'inline element'.

Block-level elements usually start on a new line (and end) when displayed in the browser.

Examples: <h1>, <p>, <ul>, <table>

HTML Inline Element

Inline elements usually do not start on a new line when displayed.

Examples: <b>, <td>, <a>, <img>

HTML <div> Element

The HTML <div> element is a block-level element and is used as a container for other HTML elements.

The <div> element has no specific meaning. In addition, since it is a block-level element, the browser will display a line break before and after it.

If used with CSS, the <div> element can be used to set style properties for large content blocks.

Another common use of the <div> element is document layout. It replaces the outdated method of defining layout with tables. Using the <table> element for document layout is not the correct use of the table element. The purpose of the <table> element is to display tabular data.

HTML <span> Element

The HTML <span> element is an inline element and can be used as a container for text.

The <span> element has no specific meaning.

When used with CSS, the <span> element can be used to set style properties for part of the text.

HTML Group Tag

Tag Description
<div> Define a division or section in the document.
<span> Define span, used to combine inline elements in the document.