bembry.org
Home / Technology / Web_development / Html

<SPAN> and <DIV>

DIV and SPAN are both tags used to set the properties for a particular piece of text. They are most often used as part of CSS to set style properties. Each works a little differently, however, and it is important to understand the difference.

<span>
The <span> tag creates an inline element and works in much the same was as other inline tags like <b>, <i>, and <u>. A span can be inside of a paragraph, headline, or any other container element.

Example:
This sentence uses a <span> span </span> inside of it.
<span> This whole sentence is inside a span. </span>

<div>
A <div> is a containter element itself and works much the same way as <p> or <h1>. When you code for a <div>, the division will start on a new line and can contain any other container elements, including tables, paragraphs, or headlines.

<div> This paragraph is in a div.
Notice how the color goes all across the page instead of being only where the text is.
</div>
Restricted access