HTML Block Elements

The HTML Elements are either treated as a block level element or an inline element.

The HTML Block Elements usually starts and ends with new line by default like <h1>, <p> & <table>

The inline elements starts and ends in the same line by default like <b>, <a> & <img>

HTML Elements can be grouped in to blocks, like content block, navigation block, etc.

There are two basic tags which is used to group HTML elements in to blocks.

  1. <div>
  2. <span>

Div in HTML

<div> tag is a block level HTML element mainly used as a container to group other HTML elements.

<div> tag itself doesn't have any special meaning. It can be used to group neighboring elements inside a block so that CSS styles can be applied to that group.


Span in HTML

<span> tag is an inline HTML element mainly used to contain elements of the same line like text.


Example


<div>
<h3>This is a Heading.</h3>
<p>This is a <span>Paragraph.</span></p>
</div>
		

Preview

The use of <div> and <span> in the above code will not cause any change as the tags itself doesn't have any special meaning.


Next Lesson > HTML Form Tutorial