I am curious, the span tag seems to work the same as a div.
Two block level elements (divs) will be displayed one after each other vertically, whereas two inline elements (spans) will be displayed one after each other horizontally.
To understand the difference in visual terms, it might help to think of the
The main difference is that
Both can be styled using CSS to act however you wish but out of the box you would normally use
Some things will affect inline and block elements different, for example you cannot put a height onto a
Both Nick and Toby have answered your question nicely, but to take it one level further.
However, bending them to act like one another isn't recommended. And, there are rules in HTML that actually prevent using block-level elements inside of other elements (mostly inline elements like the
Try to think of them as semantic elements. Use
Having said this, HTML5 has a plethora of semantic elements that should significantly reduce needing to use either of these generic tags. Using semantic tags is highly recommended over adding copious amounts of divs and spans.
protected by Community♦ Feb 27 '13 at 16:15
Thank you for your interest in this question.
Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.
Would you like to answer one of these unanswered questions instead?