Results 1 to 10 of 10

Thread: Can get my HTML tables to render correctly.

  1. #1

    Thread Starter
    Addicted Member Martin Wilson's Avatar
    Join Date
    Mar 2002
    Location
    :)
    Posts
    236

    Angry Can get my HTML tables to render correctly.

    Code:
    <table border="1" width="400" height="200">
      <tr>
        <td width="20" > One </td>
        <td width="20" > Two </td>
        <td width="20" > Three </td>
        <td width="20" > Four </td>
        <td > Padding </td>
      </tr>
      <tr>
        <td colspan="5">Not much text!</td> 
        <!-- <td colspan="5">There is quite a lot of text here...and it messes up the table :(</td> -->
      </tr>
      <tr>
        <td colspan="5">Test</td>
      </tr>
    </table>
    Stick this code in an html file and view it...that is how is should look. The first four cells are small and the forth fills up the width.
    Now comment the first bold line and uncomment the second. Now the width of the cells on the first row are buggered WTH is happening?

    I am using IE 6 btw.

  2. #2

  3. #3

    Thread Starter
    Addicted Member Martin Wilson's Avatar
    Join Date
    Mar 2002
    Location
    :)
    Posts
    236
    That is wrong, the first four cells are too wide...they should be about half that width.

    The two tables should look the same:

  4. #4
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    Oh yeah I see, sorry. Are you allowed to add "px" to the width attributes, I can't remember? Maybe that would fix it. IE is buggy with a lot of things it does, and I assume this is another one of its bugs. Is it alright in Mozilla/Netscape/Opera?

  5. #5

    Thread Starter
    Addicted Member Martin Wilson's Avatar
    Join Date
    Mar 2002
    Location
    :)
    Posts
    236
    I don't have Mozilla/Netscape/Opera, but the page will be viewed using IE 99% of the time. Maybe I can replace the 5 columns in the first row with another table. Silly IE

  6. #6
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    I don't know exactly what you want, but maybe you would be better off using CSS and DIVs, there's a good chance you could solve this problem then.

  7. #7

    Thread Starter
    Addicted Member Martin Wilson's Avatar
    Join Date
    Mar 2002
    Location
    :)
    Posts
    236
    I am already using CSS...same problem...I'll give divs a try but I am not sure if they'll do what I want...

  8. #8

    Thread Starter
    Addicted Member Martin Wilson's Avatar
    Join Date
    Mar 2002
    Location
    :)
    Posts
    236
    I think i'll have to use spans instead.
    Last edited by Martin Wilson; Jul 7th, 2002 at 08:58 AM.

  9. #9
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    You could try something like this with DIVs, it seems to get rid of the problem:

    Code:
    <head>
      <style type="text/css"><!--
        .cell, .cell2 {
           border:1px solid black;
        }
        .cell2 {
           float:left; 
           width:20px;
        }
        .table {
          border:1px solid black;
        }
      --></style>
    </head>
    
    <body>
      <div class="table">
        <div class="cell2">One</div>
        <div class="cell2">Two</div>
        <div class="cell2">Three</div>
        <div class="cell2">Four</div>
        <div class="cell">Padding</div>
        <div class="cell">There is quite a lot of text here... does it still mess up the "table"?</div>
        <div class="cell">Test</div>
      </div>
    </body>
    The only problem is (if you don't want this effect that is), is that if the browser is too small the "cells" break down a line. I'm sure there is a work around though.

  10. #10

    Thread Starter
    Addicted Member Martin Wilson's Avatar
    Join Date
    Mar 2002
    Location
    :)
    Posts
    236
    I found a fix:
    table-layout: fixed;
    That stops IE doing what it wants and solves all the problems

Posting Permissions

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



Click Here to Expand Forum to Full Width