Forum Moderators: not2easy

Message Too Old, No Replies

I hate to admit it but.....

...I think the time has come...

         

jimbob

8:46 am on Mar 13, 2004 (gmt 0)

10+ Year Member



...can anyone explain to me the difference between a 'div' and a 'span'? I know I ought to know this by now..........

yours ashamedly,

Jim!

Jaze

9:07 am on Mar 13, 2004 (gmt 0)

10+ Year Member



<div> is for a block level element - multi line, whereas <span> is more for one liners (in-line), or two or three words.

In it's most basic explanation. Kind of like <p> is for block level and <b> is for in-line.

HTH

mipapage

9:15 am on Mar 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hey jim,

A div is a block level element, whereas a span is an inline element.

Basically, think of a div as a conataining block. It can contain paragraphs and images etc. where a span works inline, that is, within an element like a div or paragraph tags, and is commonly used to style text.

Neither tag contains any real semantic value.

Check out the specs [w3.org] on block level and inline...

rogerdp

9:16 am on Mar 13, 2004 (gmt 0)

10+ Year Member



<div> is a block-level element (defaults to display: block) and can include block-level and inline elements

<span> is an inline element (defaults to display: inline) and can only include inline elements

see www.htmlhelp.com

jimbob

11:46 am on Mar 13, 2004 (gmt 0)

10+ Year Member



thanks all....I get it now.
Jim

ronin

3:57 pm on Mar 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



SuzyUK once gave a wonderful explanation, where, if I recall correctly, she likened <div>s to shelves in a supermarket and <span>s to boxes on the shelves.

Thus <div>s may contain other <div>s and <div>s may contain <span>s. But <span>s may not contain <div>s.

Until that explanation I never properly understood what "inline" was supposed to mean.

rogerdp

8:17 pm on Mar 14, 2004 (gmt 0)

10+ Year Member



I've never seen shelves contain shelves in the supermarket. :P

jimbob

11:18 pm on Mar 14, 2004 (gmt 0)

10+ Year Member



Fair point well argued :-)

photon

6:56 pm on Apr 12, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Here's SuzyUK's analogy: [webmasterworld.com...] message #30.

vkaryl

12:17 am on Apr 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've never seen shelves contain shelves in the supermarket. :P

I have. Various of the local group of superdoopermarketgroupers use "stackers/splitters" in their shelving-sets....