|
-
May 7th, 2002, 10:50 PM
#1
Thread Starter
Addicted Member
What's the difference between <div> and <span>
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
-
May 8th, 2002, 08:48 AM
#2
Frenzied Member
DIV is block level, SPAN is inline. That is the difference.
For more on that, check with the W3C.
Travis, Kung Foo Journeyman
As always, RTFM.
WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
YBMS, but Mozilla doesn't.
-
May 22nd, 2002, 04:27 PM
#3
Originally posted by CiberTHuG
DIV is block level, SPAN is inline. That is the difference.
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".
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>
-
May 23rd, 2002, 11:10 AM
#4
Black Cat
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.
Josh
Get these: Mozilla Opera OpenBSD
I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.
-
May 23rd, 2002, 11:53 AM
#5
Frenzied Member
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.
Travis, Kung Foo Journeyman
As always, RTFM.
WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
YBMS, but Mozilla doesn't.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|