Xbox Mod Chips - Mobile Phone - Loan - Free Ringtones - Online Loans

PDA

View Full Version : whats the difference between a div and a span tag?


mnn888
Jan 31st 2008, 1:25 pm
whats the difference between a div and a span tag?

shallowink
Jan 31st 2008, 1:27 pm
Div is a block level element. Span is inline. Examples provided at this site:

http://www.learnwebdesignonline.com/htmlcourse/span-div.htm

Cybernaut
Jan 31st 2008, 1:55 pm
In simpler words, DIV starts from a new line while SPAN does not.

<span>Sweet</span> <span>Home</span> will display:

Sweet Home

while <div>Sweet</div> <div>Home</div> will display:

Sweet
Home

- Cybernaut

mnn888
Jan 31st 2008, 2:06 pm
thanks, i always wondered!

Cybernaut
Jan 31st 2008, 2:19 pm
Also note, this behavior is by default only and you can change this behavior using styles:

<span style="display:block;"> </span> will act as a div (block)

<div style="display:inline;"> </div> will act as a span (inline)

Cybernaut.

Dolbz
Jan 31st 2008, 4:06 pm
Also note, this behavior is by default only and you can change this behavior using styles:

<span style="display:block;"> </span> will act as a div (block)

<div style="display:inline;"> </div> will act as a span (inline)


But you really shouldn't. That's why they're separate elements. I can't imagine any good reasons to reverse this behaviour

2mk_atspace
Feb 1st 2008, 2:00 am
<div>Hello</div> Hahaha
Result :
Hello
Hahaha

<span>Hello</span> Hahaha
Hello Hahaha

nico_swd
Feb 1st 2008, 3:25 am
http://www.geocities.com/mpetrie98/MasterOfTheObvious.jpg