1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

whats the difference between a div and a span tag?

Discussion in 'JavaScript' started by mnn888, Jan 31, 2008.

  1. #1
    whats the difference between a div and a span tag?
     
    mnn888, Jan 31, 2008 IP
  2. shallowink

    shallowink Well-Known Member

    Messages:
    1,218
    Likes Received:
    64
    Best Answers:
    2
    Trophy Points:
    150
    #2
    shallowink, Jan 31, 2008 IP
  3. Cybernaut

    Cybernaut Peon

    Messages:
    408
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #3
    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
     
    Cybernaut, Jan 31, 2008 IP
  4. mnn888

    mnn888 Member

    Messages:
    92
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #4
    thanks, i always wondered!
     
    mnn888, Jan 31, 2008 IP
  5. Cybernaut

    Cybernaut Peon

    Messages:
    408
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #5
    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.
     
    Cybernaut, Jan 31, 2008 IP
  6. Dolbz

    Dolbz Peon

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    But you really shouldn't. That's why they're separate elements. I can't imagine any good reasons to reverse this behaviour
     
    Dolbz, Jan 31, 2008 IP
  7. 2mk_atspace

    2mk_atspace Well-Known Member

    Messages:
    317
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    108
    #7
    <div>Hello</div> Hahaha
    Result :
    Hello
    Hahaha

    <span>Hello</span> Hahaha
    Hello Hahaha
     
    2mk_atspace, Feb 1, 2008 IP
  8. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #8
    [​IMG]
     
    nico_swd, Feb 1, 2008 IP