HTML <div> and <span>


HTML can group elements together using <div> and <span>.


HTML Block Elements

Most HTML elements are defined asBlock-level elementsorInline elements。

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

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


HTML Inline Elements

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

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


HTML <div> element

The HTML <div> element is a block-level element that can be used as a container for grouping other HTML elements.

The <div> element has no specific meaning. Apart from that, since it is a block-level element, the browser displays line breaks before and after it.

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

Another common use of the <div> element is document layout. It replaces the old method of using tables to define layout. Using the <table> element for document layout is not the correct use of a table. The role of the <table> element is to display tabular data.


HTML <span> element

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

The <span> element also has no specific meaning.

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


HTML Grouping Tags

Tags Description
<div> Defines a section in a document, block-level.
<span> Used to group inline elements in a document, inline element.
other extensions