Simple discussion: Span vs. Div Tags

A tiny question but many times it has been asked in various discussion forms and interviews about the difference between Span and Div tags.

Div stands for Division which means to divide a place or body or page where need to show some tasks. So, Div tag is nothing but its Divide a page or in another words its a block element which blocks the entire page withing tags

Span is an inline element.So, its print in the same line.

Check following example:

<html>
<head>
<title>Div vs Span</title></head>
<body>
<P><b>Difference : Div and Span</b></p></span></em>

<b>Span Example</b><br/>
<span>This line is within the span tag and will output in same line.</span>
<p>
<b>Div Example</b></p>

<div>This line is within the div tag.
<p>We can use paragraphs within division but not divisions within paragraphs.</p>
</div>
</body>
</html>

Leave A Reply