Friday, April 11, 2008

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.

1.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

2.On the other hand, 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>

<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>

No comments:

Post a Comment