div vs span

  • VentsyV
  • Student
  • Student
  • VentsyV
  • Posts: 65

Post 3+ Months Ago

What is the difference between the div and span tags if any ? w3schools.com describes both tags as: Defines a section in document.
Thanks
  • Impel GD
  • Professor
  • Professor
  • Impel GD
  • Posts: 834
  • Loc: Cologne, Germany

Post 3+ Months Ago

First Google result for 'difference div span':

http://webdesign.about.com/cs/htmltags/a/aa011000a.htm

Quote:
The primary difference between the <span> and <div> tags is that <span> doesn't do any formatting of it's own. The <div> tag acts as a paragraph break, because it is defining a logical division in the document. The <span> tag simply tells the browser to apply the style and align rules to whatever is within the <span>.


Had wondered this myself.
  • sycofi5h
  • Expert
  • Expert
  • sycofi5h
  • Posts: 506
  • Loc: Australia

Post 3+ Months Ago

i just use which ever one i am more confortable with so i use div
  • Mas Sehguh
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1853

Post 3+ Months Ago

The difference is that DIV is a block-level element and SPAN is a text-level element. DIV may contain text and may contain other block-level elements, such as P and UL, whereas SPAN may not contain other block-level elements, and SPAN may not be a direct child of the BODY element. (It must be inside a text-containing element such as P or DIV or TD.)

Quite often, DIV is used for CSS rules when another element could be used. I often see something like

Code: [ Select ]
<div class="navigation">
<ul>
<li><a href="athoetu">blah</a></li>
...
</ul>
</div>
  1. <div class="navigation">
  2. <ul>
  3. <li><a href="athoetu">blah</a></li>
  4. ...
  5. </ul>
  6. </div>


And in that case, <ul class="navigation"> could have been used. The HTML behind many CSS layouts involves unnecessary 'DIV Soup.'
  • sycofi5h
  • Expert
  • Expert
  • sycofi5h
  • Posts: 506
  • Loc: Australia

Post 3+ Months Ago

very true sam that is why i use divs too
  • VentsyV
  • Student
  • Student
  • VentsyV
  • Posts: 65

Post 3+ Months Ago

Ok I got it thanks. I should have checked google ...
thanks
  • sycofi5h
  • Expert
  • Expert
  • sycofi5h
  • Posts: 506
  • Loc: Australia

Post 3+ Months Ago

dont worry about it
  • ds772123
  • Born
  • Born
  • ds772123
  • Posts: 1

Post 3+ Months Ago

The HTML tag SPAN works more like a marker with which you mark a place to format. DIV layout for longer so you need 2D.

Post Information

  • Total Posts in this topic: 8 posts
  • Users browsing this forum: No registered users and 50 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.