Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9

Thread: Span <> Div

  1. #1
    Regular Coder
    Join Date
    Dec 2002
    Location
    France
    Posts
    522
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Span <> Div

    what is the difference between a div and a span, except the display block for div and display inline for span ?

    thank you

  • #2
    Senior Coder Mhtml's Avatar
    Join Date
    Jun 2002
    Location
    Sydney, Australia
    Posts
    3,531
    Thanks
    0
    Thanked 1 Time in 1 Post
    Well apart from that none.

  • #3
    Regular Coder
    Join Date
    Dec 2002
    Location
    France
    Posts
    522
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ok

    thank you

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    Ames, IA, USA
    Posts
    373
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, there's one more. In strict XHTML 1.0, you can nest divs but you can't nest spans.
    Need more emoticons?
    Visit Catman's Private Stock

  • #5
    Regular Coder
    Join Date
    Dec 2002
    Location
    France
    Posts
    522
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ?

    I don't really understand the meaning of nesting !

  • #6
    Regular Coder
    Join Date
    Jun 2002
    Location
    Ames, IA, USA
    Posts
    373
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Nesting:
    Code:
    <div>
    This is the outer div.
      <div>
      This is the first inner div.
      </div>
      <div>
      This is the second inner div.
        <div>
        This is a third level div.
        </div>
      </div>
    </div>
    Need more emoticons?
    Visit Catman's Private Stock

  • #7
    Regular Coder
    Join Date
    Dec 2002
    Location
    France
    Posts
    522
    Thanks
    0
    Thanked 0 Times in 0 Posts

    xhtml

    I have tried

    <?xml version="1.0" encoding="iso-8859-1"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 strict//EN" "DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
    <head>
    </head>
    <body id="body">
    <span>
    This is the outer span.
    <span>
    This is the first inner span.
    </span>
    <span>
    This is the second inner span.
    <span>
    This is a third level span.
    </span>
    </span>
    </span>
    </body>
    </html>

    and the same with div

    both are working

  • #8
    Regular Coder
    Join Date
    Jun 2002
    Location
    Ames, IA, USA
    Posts
    373
    Thanks
    0
    Thanked 0 Times in 0 Posts
    There's a difference between "working" and "valid" -- nesting spans will work just fine on most current browsers, but it's not valid XHTML.
    Need more emoticons?
    Visit Catman's Private Stock

  • #9
    Regular Coder
    Join Date
    Dec 2002
    Location
    France
    Posts
    522
    Thanks
    0
    Thanked 0 Times in 0 Posts

    validator

    with span I get

    Line 8, column 5: document type does not allow element "span" here; missing one of "p", "h1", "h2", "h3", "h4", "h5", "h6", "div", "pre", "address", "fieldset", "ins", "del" start-tag
    <span>
    ^


    and with div it works

    perfect ! I stop using span

    thank you


  •  

    Posting Permissions

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