SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: Span & Div

  1. #1
    SitePoint Wizard simplecode's Avatar
    Join Date
    Jun 2006
    Posts
    1,129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Span & Div

    whats the difference between span and div tag

  2. #2
    SitePoint Addict
    Join Date
    Nov 2004
    Location
    London
    Posts
    248
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    div is a block level element and span is an inline element.

  3. #3
    SitePoint Enthusiast johnmanoahs's Avatar
    Join Date
    Jul 2004
    Location
    India
    Posts
    46
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The basic difference is that div displays a line-break by default whereas span doesn't. Imagine a phrase like "Mary had a little lamb" and if you need to apply a style for the word "little", you can use the span and then define a style. Div is more like a block or a paragraph.

    - John
    If you think you are too small to make an
    influence, try sleeping with a mosquito in a closed room.

  4. #4
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,871
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    divs can contain paragraphs which can contain spans but spans can't contain paragraphs and paragraphs can't contain divs.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •