Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > div versus span tags

Reply
Thread Tools

div versus span tags

 
 
TheKeith
Guest
Posts: n/a
 
      10-17-2003
I know the basic difference between these two tags, but there is one thing I
don't understand about the span tag? Unlike the div tag, specifying a width
and height of a span tag doesn't work unless you have "position:absolute"
within it. Why is this? What does the position style have to do with the
width and height styles?


 
Reply With Quote
 
 
 
 
Eric Bohlman
Guest
Posts: n/a
 
      10-17-2003
"TheKeith" <(E-Mail Removed)> wrote in
news:(E-Mail Removed):

> I know the basic difference between these two tags, but there is one
> thing I don't understand about the span tag? Unlike the div tag,
> specifying a width and height of a span tag doesn't work unless you
> have "position:absolute" within it. Why is this? What does the
> position style have to do with the width and height styles?


First of all, a terminological nitpick: *tags* don't have properties,
*elements* do. Tags are just the markers that show where elements begin
and end; they're really a sort of labelled parentheses.

Span elements are considered inline elements, whereas div elements are
considered block elements. You can think of block elements as "containers"
(which may contain sub-containers), whereas inline elements are content
that doesn't contain any further containers. Properties like height and
width apply only to block elements. The height and width of inline
elements is determined by the document flow.

However, when you position something absolutely, you're taking it out of
the normal document flow, so it doesn't get to pick up properties from its
container. A lot of the normal distinctions between block and inline
elements vanish when you position them absolutely.
 
Reply With Quote
 
 
 
 
TheKeith
Guest
Posts: n/a
 
      10-17-2003

"Eric Bohlman" <(E-Mail Removed)> wrote in message
news:Xns94178E86DF008ebohlmanomsdevcom@130.133.1.4 ...
> "TheKeith" <(E-Mail Removed)> wrote in
> news:(E-Mail Removed):
>
> > I know the basic difference between these two tags, but there is one
> > thing I don't understand about the span tag? Unlike the div tag,
> > specifying a width and height of a span tag doesn't work unless you
> > have "position:absolute" within it. Why is this? What does the
> > position style have to do with the width and height styles?

>
> First of all, a terminological nitpick: *tags* don't have properties,
> *elements* do. Tags are just the markers that show where elements begin
> and end; they're really a sort of labelled parentheses.
>
> Span elements are considered inline elements, whereas div elements are
> considered block elements. You can think of block elements as

"containers"
> (which may contain sub-containers), whereas inline elements are content
> that doesn't contain any further containers. Properties like height and
> width apply only to block elements. The height and width of inline
> elements is determined by the document flow.
>
> However, when you position something absolutely, you're taking it out of
> the normal document flow, so it doesn't get to pick up properties from its
> container. A lot of the normal distinctions between block and inline
> elements vanish when you position them absolutely.


Thanks a lot. That explains it.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Mozilla versus IE versus Opera versus Safari Peter Potamus the Purple Hippo Firefox 0 05-08-2008 12:56 PM
WebControl using SPAN tag instead of DIV tags Lloyd Dupont ASP .Net 2 01-08-2006 03:13 PM
span versus div KiwiBrian HTML 28 11-25-2004 12:25 PM
DataGrid (body only) contained in <span>...</span> tags Dan Bishop ASP .Net Datagrid Control 2 06-07-2004 04:00 PM
Redrawing of Internet Explorer Tables vs Div/Span tags sherpaa HTML 2 06-01-2004 09:38 PM



Advertisments