www.webdeveloper.com
Results 1 to 8 of 8

Thread: when I need to use colspan ?

Hybrid View

  1. #1
    Join Date
    Nov 2004
    Location
    xxxyyy
    Posts
    357

    when I need to use colspan ?

    I am not comfortable using colspan in HTML table. I dont understand under what circumstances one should be use colspan.

    Can anybody please explain situations where colspan needs to be used.

    Thanks

  2. #2
    Join Date
    Mar 2011
    Posts
    1,140
    You use 'colspan' on a <td> to set the number of columns in your table that you want the <td> to occupy. This is typically used when there will be rows in your <table> that will have a different number of columns. For example:
    Code:
    <table>
     <tr>
      <td>Some data</td>
      <td>Some data</td>
      <td>Some data</td>
     </tr>
     <tr>
      <td>Some data</td>
      <td colspan="2">Two columns of data</td>
     </tr>
    </table>
    Rick Trethewey
    Rainbo Design

  3. #3
    Join Date
    Nov 2004
    Location
    xxxyyy
    Posts
    357
    Ok. Thaks for the post.
    We could just use a blank td with nbsp ? Why colspan ?

  4. #4
    Join Date
    Mar 2011
    Posts
    1,140
    It's a matter of controlling the appearance of the table. If your rows have different numbers of columns and you don't use colspan anywhere, the browser will decide for itself which <td> to expand to the full width of the table.
    Rick Trethewey
    Rainbo Design

  5. #5
    Join Date
    Nov 2002
    Posts
    2,632
    Also, if you use borders in your tables, it will be noticeable that you have a <td> tag with a nbsp in it.

  6. #6
    Join Date
    Apr 2012
    Location
    delhi
    Posts
    7
    Table cells can span across more than one column or row. The attributes COLSPAN ("how many across") and ROWSPAN ("how many down") indicate how many columns or rows a cell should take up.

    For example, we might want to create header cells for each department in our table of names and phone numbers. In this table, the header cells in the first and fifth rows span across two columns to indicate the department for each group of names.

    <TABLE BORDER=2 CELLPADDING=4>
    <TR> <TH COLSPAN=2>Production</TH> </TR>
    <TR> <TD>Raha Mutisya</TD> <TD>1493</TD> </TR>
    <TR> <TD>Shalom Buraka</TD> <TD>3829</TD> </TR>
    <TR> <TD>Brandy Davis</TD> <TD>0283</TD> </TR>
    <TR> <TH COLSPAN=2>Sales</TH> </TR>
    <TR> <TD>Claire Horne</TD> <TD>4827</TD> </TR>
    <TR> <TD>Bruce Eckel</TD> <TD>7246</TD> </TR>
    <TR> <TD>Danny Zeman</TD> <TD>5689</TD> </TR>
    </TABLE>

    which gives us:

    Production
    Raha Mutisya 1493
    Shalom Buraka 3829
    Brandy Davis 0283
    Sales
    Claire Horne 4827
    Bruce Eckel 7246
    Danny Zeman 5689

  7. #7
    Join Date
    Apr 2012
    Posts
    1
    A milling machine is a machine tool used to machine solid materials. Milling machines are often classed in two basic forms, horizontal and vertical, which refer to the orientation of the main spindle. Both types range in size from small, bench-mounted devices to room-sized machines.
    Liquid Filling Machine

  8. #8
    Join Date
    Aug 2011
    Location
    Worthing, West Sussex
    Posts
    96
    Tables are terrible! Use div tags.
    Titanium Web Designs Ltd - Bespoke websites and online systems

Thread Information

Users Browsing this Thread

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

Posting Permissions

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



Recent Articles