Welcome our webmaster and SEO forum
Please enjoy the forum, contribute what you can, and wind up the Moderators!
Results 1 to 2 of 2

Thread: Div or Span?

  1. #1
    ForumJoiner is offline Member
    Join Date
    Mar 2007
    Posts
    50

    Default Div or Span?

    Span is used when you want to change the properties of an object, without affecting its position. Compare this:

    This is a
    red text
    inside a green text.

    with:
    This is a red text inside a green text.


    In the first case, we have a div inside a div. In the second case we have a span inside a div.
    The CSS code is the same, only the HTML code differs.

    HTML code - Div inside a Div
    Code:
    <html>
        <head>
            <link 
                rel = "stylesheet" 
                type = "text/css" 
                href = "example.css" 
            />
        <head>
        <body>
            <div id = "mydiv">
                This is a <div id = "myspan">red text</div> inside a green text.
            </div>
        </body>
    </html>
    HTML code - Span inside a Div
    Code:
    <html>
        <head>
            <link 
                rel = "stylesheet" 
                type = "text/css" 
                href = "example.css" 
            />
        <head>
        <body>
            <div id = "mydiv">
                This is a <span id = "myspan">red text</span> inside a green text.
            </div>
        </body>
    </html>
    CSS code
    Code:
    #mydiv
    {
            color : green;
    }
     
     
    #myspan
    {
            color : red;
    }

    Please see the attachments for the example code.

  2. #2
    Join Date
    Feb 2007
    Posts
    122

    Default

    Span is what is known as an inline element, meaning that it doesn't create line breaks before or after the element.

    Div is what is known as a block element.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Web news readers have greater attention span: study
    By rakib in forum General Webmaster Talk
    Replies: 0
    Last Post: 04-01-2007, 05:28 AM

Bookmarks

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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124