Is there a semantic difference <span>'s and <div>'s?

Posted by DavidR on Stack Overflow See other posts from Stack Overflow or by DavidR
Published on 2010-06-02T21:54:27Z Indexed on 2010/06/02 22:04 UTC
Read the original article Hit count: 213

Filed under:
|
|
|

I know when coding HTML, I'm supposed to keep semantics in mind, e.g., h1 needs to be a main header, h2 needs to be a subheader, tables need to be tables, use <em> for emphasis instead of <i>, etc. Is there a proper difference between divs and spans except one is a block and the other is in-line?

When I was learning I was told that <span>'s were for styling text mid-line. If I had a small blurb of text that I needed positioned at a certain point in my webpage, one that doesn't warrent a <p> tag, would I use a span should I stick with div's? What if that text needs to cover two lines (i.e., it needs a width) if it contains nothing but text, what should I use?

© Stack Overflow or respective owner

Related posts about html

Related posts about div