Wednesday, August 06, 2008

Dev : div vs span tag

Some of us may come across with the <div>and <span> tag before. What is the difference? Both usage seems almost the same.

Well, not exactly the same, but yes, almost. Both are elements of a document, but <div>is a block element and <span> is an inline element. And what is block and inline? Block elements take the whole section of a page, at least a whole full line, but inline will use as little space as possible, just like filling a gap.

DIV
I am <div>a</div>boy.
will produce
I am
a
boy.

yet,SPAN
I am <span>a</span> boy
will produce
I am a boy.

So, can you see the differences now?

1 comment:

Beverly's Secret said...

yes, i can :)