Home / ASP.NET Wiki / HTML / Difference between div and span tag

Difference between div and span tag

 Rate It (5)

The basic difference between them is ,div is block level  element and span is inline level element.
<span> and <div> tags both allow a Web designer to style text and add other formatting attributes to their Web page. They are not interchangeable tags, though. <div> tags are block-level elements, whereas <span> tags are not.

Div

   <div> tags are block elements that allow you to position elements contained within them


Example

<div style="color:#00FF00">
  <h3>Welcome to Studentacad.com</h3>
  <p>This is a paragraph.</p>
</div>

Span

<span> tags are NOT block elements

<p>This Blog is manage By<span class="blue">Aamir Hasan</span> (CEO)</p>

 

Revision number 1, Sunday, March 21, 2010 6:53:23 PM by Aamir Hasan
This is not the most up to date version of this article. The most recent version can be found here.

Comments

Another difference I see would be that you can use span> in a div> but not vice versa, strictly speaking.

Better explain when to use Div and when use span!

Shortcuts

Table of Contents

Top Wiki Contributors

(last 30 days)

  1. abiruban (1)