I use <div> but never use <span>. Sometimes I've seen things where <span> was used where I'd have used a <div> and it looks really strange.
Is it just a matter of preference?
I'm a <div> kinda guy. How 'bout you? Join the <div> generation?
cudabean
Printable View
I use <div> but never use <span>. Sometimes I've seen things where <span> was used where I'd have used a <div> and it looks really strange.
Is it just a matter of preference?
I'm a <div> kinda guy. How 'bout you? Join the <div> generation?
cudabean
DIV is block level, SPAN is inline. That is the difference.
For more on that, check with the W3C.
In simple terms, generally a div is a block-level element, meaning that a div will create a "block" around whatever it encapsulates. A span takes the shape of whatever it encapsulates. It doesn't create a "block".Quote:
Originally posted by CiberTHuG
DIV is block level, SPAN is inline. That is the difference.
Code:<html>
<body topmargin="0" leftmargin="0">
<div style="background-color: gold;">This is my block<br/>I can put many things into it<p>note the color fills the whole "block"</p></div>
<span style="background-color: pink;">This is my span<br/>I can put many things into it<p>note the color wraps around ("inline")</p></span>
</body>
</html>
Note that CSS can determine whether a tag is block or inline (or neither), which really should make the div and span tags obsolete as we move towards XML.
True that.
But I'd like a generic tag that doesn't have a representative conitation (and isn't predefined in the XHTML DTD), so I can keep making invisible containers to help with layout.