You must Sign In to post a response.
  • Category: HTML

    Colspan and div difference

    hi everybody
    can someone tell me the difference between colspan and div along with the usage
  • #643289
    Hi,

    Once you try below sample HTML code you will easily understand the difference between the DIV and colspan tags

    Please check below HTML tag to know how to use colspan,

    <html>
    <body>

    <table width="100%" border="1">
    <tr>
    <th>Name</th>
    <th>Address</th>
    </tr>
    <tr>
    <td colspan="2">Test Colspan1</td>
    </tr>
    <tr>
    <td colspan="2">Test colspan2</td>
    </tr>
    </table>

    </body>
    </html>


    Below is the Div tag sample.

    <html>
    <body>

    <h2>This is outside Div tag</h2>
    <p>This is a paragraph tag outside Div tag.</p>

    <div style="color:#00FF00">
    <h2>This is a header inside Div Tag</h2>
    <p>This is a paragraph tag Inside DIV tag</p>
    </div>
    </body>
    </html>


    Regards,
    Asheej T K

  • #643302
    colspan is the property of table's td tag. It is generally used to merge more than 1 column.

    Ex :

    <table border="1">
    <tr>
    <td colspan="2" style="width:200px;text-align:center;">Date</td>
    <td>Amount</td>
    </tr>
    <tr>
    <td>From</td>
    <td>To</td>
    <td></td>
    </tr>
    <tr>
    <td>02-05-2011</td>
    <td>03-05-2011</td>
    <td>5000</td>
    </tr>
    </table>


    The <div> is a html tag which defines a division or a section in an HTML document.

    Ex :

    <div style="width:250px;height:150px;">
    Sample Text, Sample Text.
    </div>

    If it helps you then Rate this.

    Best Regards,
    Manoranjan Sahoo
    http://www.dotnetsquare.com
    Blog: http://blog.msahoo.net

  • #643313
    Div is a tag inside which we place our controls :

    <div>
    <asp:TextBox ID="txt1" runat="server" Text = "Welcome"/>
    </div>


    Whereas colspan is a tag inside table control which is used to merge 2 columns.


    <table>
    <tr>
    <td >Name</td>
    <td colspan="2"><asp:TextBox ID="txtname" runat="server"/></td>
    </tr>
    <tr>
    <td>age</td>
    <td><asp:TextBox ID="txtage" runat="server"/></td>
    <td><asp:TextBox ID="txtmonths" runat="server"/></td>
    </tr>
    </table>

    Regards,
    Sugandha
    Microsoft Certified Technology Specialist
    MY Blog..

  • #643338
    Thank you everybody

    Kamlesh Mohanty

    Regards
    Kamlesh Mohanty

  • #643460
    div is used to div page into layers.it is used in css
    colspan is used give space between the cells in the table

  • #643491
    The main difference between div and colspan are as follows:-

    1.Colspan is used in table.

    2.Colspan is property of table wheareas div is act as a html control.

    3.Colspan generally used in column of a table wheareas colspan cannot be used in div.

    4.Example
    Example For DIV
    ---------------
    <div>Heading</div>
    <div>Name: XYZ </div>
    <div>Email: xyz@gmail.com </div>

    Example For COLSPAN
    -------------------
    <table>
    <tr><td colspan="2">Heading</td></tr>
    <tr><td>Name:</td><td>XYZ</td></tr>
    <tr><td>Email:</td><td>xyz@gmail.com</td></tr>
    </table>

  • #643804
    colspan used to merge more than 1 column.it is TD's property.



    <table border="1" cellspacing=0 cellpading=5>
    <tr>
    <td>TD1</td>
    <td>TD2</td>
    <td>TD3</td>
    </tr>


    <tr>
    <td colspan="2">TD1</td>
    <td>TD2</td>
    </tr>

    </table>

    The <div> is a html tag which defines a division in an HTML document.

    <div>
    Details
    </div>

    <div>
    Details1
    </div>

    Regards
    Mr.Rajesh
    Software Engg.

  • #644060
    Hi,

    colspan
    1. It is used in the td tag.
    2. Used to merge two columns to make a single column.
    Exmple:

    <td colspan="2">


    div tag
    1. It is used to divide the html page into different sections
    2. Inside div tag you place other tag.
    3. it can identified using id property.


    <div id="div1">


    Vijayalakshmi G M
    IT Professional Trainer
    www.wincorporatetraining.com

  • #644721
    Following are the characteristics div Tag::

    As the name indicates, the div tag defines a 'division' in a web page.
    div is a block-element; its default display value is "block".
    div tag is commonly used while creating Css based layouts in html.
    by default, a line-break is placed before and after this element.


    Following are the characteristics span tag::

    span tag makes no visual difference in the page, unless customised with style attribute.
    span is an in-line element.
    span is commonly used to stylize texts. The in-line feature makes it easy to use custom styles without changing the layout.
    No line-breaks by default, but this can be achieved if we change its in-line nature by specifying in the style attribute to 'display:block;'


  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.