difference between span and div

http://stackoverflow.com/questions/183532/what-is-the-difference-between-html-tags-div-and-span

  • is a block tag, while is an inline tag.
  • Note that it is illegal to place a block level element within an inline element, so:
Some text that
I want
to mark</span> up</div>

…is illegal.

    • There are lots of block elements (linebreaks before and after) defined in HTML, and lots of inline tags (no linebreaks).
    • But in modern HTML all elements are supposed to have meanings: a <p> is a paragraph, an <li> is a list item, etc., and we’re supposed to use the right tag for the right purpose — not like in the old days when we indented using <blockquote> whether the content was a quote or not.
    • So, what do you do when there is no meaning to the thing you’re trying to do? There’s nomeaning to a 400px-wide column, is there? You just want your column of text to be 400px wide because that suits your design.
    • For this reason, they added two more elements to HTML: the generic, or meaningless elements <div> and <span>, because otherwise, people would go back to abusing the elements which do have meanings.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s