Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

span and div

 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's the difference between span and div ? When do you use one rather than the other ?
 
Manio Manegra
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Satou,
go for DIV when you want to pack a group of element in a single box you can apply style to.
For example put in a DIV all the elements you put in to create your menu. So you can apply styles for your menu by addressing all that style to the surrounding DIV tag.

Use SPAN tag when you want apply inline style. For example if you want to emphasize a phrase inside a wider text. You can count on SPAN to apply your style.

SPAN style does not create any discontinuity, for this very reason it's known as an inline element.
DIV style creates a discontinuity (it starts on a new line), this is why it is called a block element.

HTH
Bye
Manio
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This article explains the difference:

Span and div difference
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Very clear Thanks both of you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic