SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2001
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    colspan in tables

    This seems amazingly simple, yet is driving me up the wall. Why doesn't this table work out? I believe the colspans are the cause, but everytime I look at it - it seems OK. If the last colspan is changed to "2" it formats but the borders show something is wrong and this solution makes no sense to me. Help!!!!!!!

    <table border="1">
    <tr>
    <td width="52" height="230" colspan="1">&nbsp;</td>
    <td width="560" height="230" colspan="2">&nbsp;</td>
    </tr>
    <tr>
    <td width="212" height="200" colspan="2">&nbsp;</td>
    <td width="400" height="200" colspan="1" >&nbsp;</td>
    </table>

  2. #2
    SitePoint Enthusiast
    Join Date
    Jun 2001
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    forgot to past the last </tr>
    (this doesn't make the table work).

  3. #3
    SitePoint Wizard
    Join Date
    Jul 2001
    Location
    The Netherlands
    Posts
    2,617
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This code doesn't render, because it isn't possible. You have 4 cells, two in each row. Let's say they are arranged like below:

    Code:
    a                  b
    
    c                  d
    The positions of the letters a, b, c and d signify the places of the table cells in their rows. You want cell a to have a colspan of 1, which is possible (you don't have to add this in your code btw). Cell b is meant to span two columns, and thus it would span over cell d and the fictional cell e. This is were the first mistake appears, there is not third cell in the second row, to make up for the colspan.
    Let me ellaborate a bit more on that, cell a and cell c have the same width, they are both the first cell of their respective row. Cell b takes the place of two cells, because of the colspan="2" attribute. This would mean to complement for that, there had to be two more cells in row #2, yet there is only one.

    The same problem arises when you look at the code for the second row. You want cell c to span over two columns (and thus over two cells of the following row). Yet, there is not following row.

    Could you create an image of what you are trying to create? Then I might be able to knock up the basic table structure for you .

  4. #4
    SitePoint Enthusiast
    Join Date
    Jun 2001
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Mark, Thanks for your reply. Attaced is a gif file as I want the table. the dotted lines represent what I thought would trigger the colspans I used.
    Attached Images Attached Images

  5. #5
    blonde.... Sarah's Avatar
    Join Date
    Jul 2001
    Location
    Berkshire, UK
    Posts
    7,442
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Spock,

    try this:

    Code:
    <table border="1">
    	<tr>
    		<td height="230">& n b s p ;</td>
    		<td height="230" colspan="2">& n b s p ;</td>
    	</tr>
    	<tr>
    		<td height="230" colspan="2">& n b s p ;</td>
    		<td height="230">& n b s p ;</td>
    	</tr>
    	<tr>
    		<td width="50" height="1"><img src="trans1.gif" width="50" height="1"></td>
    		<td width="150" height="1"><img src="trans1.gif" width="150" height="1"></td>
    		<td width="400" height="1"><img src="trans1.gif" width="400" height="1"></td>
    	</tr>
    </table>
    basically because there is not any data in the table its not holding its shape and the cols are joining in the middle. the extra row which I have added at the bottom is to hold it in place so to speak with no data in it. I have used transparent.gif files to make it easier to make this row as small and as insignificant as possible.

    See how you get on by changing the widths in the third row it will change throughout.

    Sarah
    Regular user

  6. #6
    SitePoint Wizard
    Join Date
    Jul 2001
    Location
    The Netherlands
    Posts
    2,617
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry, I haven't had much time today. Sarah already took care of it, and it is exactly how I would have done it. I hope that one helps you, and thanks Sarah !
    Last edited by Mark T.; Jul 5, 2002 at 07:39.

  7. #7
    blonde.... Sarah's Avatar
    Join Date
    Jul 2001
    Location
    Berkshire, UK
    Posts
    7,442
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    so you're only perfect 99% of the time - I think we can handle that
    Regular user

  8. #8
    SitePoint Enthusiast
    Join Date
    Jun 2001
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the help. I'll give it a go.


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
  •