Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Difference between div and span tag

0.00/5 (No votes)
21 Mar 2010 1  
The basic difference between them is that a div is block level element and a span is inline level element. and tags both allow a Web

This articles was originally at wiki.asp.net but has now been given a new home on CodeProject. Editing rights for this article has been set at Bronze or above, so please go in and edit and update this article to keep it fresh and relevant.

The basic difference between them is that a div is block level element and a 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">
  <p>This is a paragraph.</p>
</div>

Span

<span> tags are NOT block elements

<p>The quick <span style="color:brown;">brown</span> fox jumps over the lazy dog.</p>

 

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here