65.9K
CodeProject is changing. Read more.
Home

Difference between div and span tag

emptyStarIconemptyStarIconemptyStarIconemptyStarIconemptyStarIcon

0/5 (0 vote)

Oct 11, 2013

CPOL
viewsIcon

13060

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

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>