how to get css code to recognize table width values

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tobas
    New Member
    • Jul 2012
    • 2

    how to get css code to recognize table width values

    this code all works except for the width values which are seemingly not recognized:

    Code:
    <head>
    <style type="text/css">
    table, td, 
    table
    {
    width:800;height:25;
    }
    table
    {
    position: absolute; right: 100px; top: 80px;
    }
    table
    {
     border-collapse:collapse; 
    }
    td
    {
      border-spacing:0px;
    }
    
    td
    {
     border-collapse:collapse; 
    }
    td
    {
      border-bottom-style:solid;
      border-bottom-width:1px;
      border-color:black;
    }
    td
    {
    background-color:grey;
    color:red;
    }
    td
    {
    text-align:center;
    }
    
    </style>
    </head>
    <body>
    <table>
    <tr>
    <td width='20'></td>
    <td width='400'>First Name:</td>
    <td width='340'>{$info['firstname']}</td>
    <td width='40'><a href='changefirstname.php'>edit</a></td>
    </tr>
    <tr>
    <td><td>Last Name:</td>
    <td>{$info['lastname']}</td>
    <td><a href='changelastname.php'>edit</td>
    </tr>
    <tr>
    <td></td>
    <td>email:</td>
    <td>{$info['email']}</td>
    <td><a href='changeemail.php'>edit</td>
    </tr>
    <tr>
    <td><td>password:</td>
    <td>********</td>
    <td><a href='changepassword.php'>edit</td>
    </tr>
    </table>
    </body>
    </html>
    Last edited by Rabbit; Jul 16 '12, 10:56 PM. Reason: Please use code tags when posting code.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Please use code tags when posting code.

    The table looks fine to me. You have to explain what you mean by not working because it seems to be working for me. You also need to tell us what browswer you're testing on. Different browsers produce different results.

    Comment

    • tobas
      New Member
      • Jul 2012
      • 2

      #3
      Sorry I was not specific, where I have put <td width....>it has not recognized so all table cells are at default width ie a equal proprtion of the total table width. (google crome)

      Comment

      • Exequiel
        Contributor
        • Jul 2012
        • 288

        #4
        every time you put width value to your table code in css, the width of your table remain in HTML... for example you put width:800;heigh t:25;. the out put to your html for table width will be 800 for width and 25 for height, so when you try to put width to your td in html tag it will remain your table width, the only changes is on your td. and I observed, your height for your table is only 25px. So when you try to make another table, it cannot be shown because of the set height to your css for table...

        Comment

        • Rabbit
          Recognized Expert MVP
          • Jan 2007
          • 12517

          #5
          You'll have to apply it in a style, and you have to do it for every cell.

          Comment

          • Exequiel
            Contributor
            • Jul 2012
            • 288

            #6
            Code:
            <style type="text/css">
            table { margin: 1em; border-collapse: collapse; box-shadow: 5px 5px 8px #999; border-radius: 15px;
            }
            td{ padding: .3em; border: 1px #FFF solid; box-shadow: 2px 2px 2px #CCC; border-radius: 2px;}
            thead { background: #00468C; }/*you can use this one if you try to put <th> tag to your table*/
            tbody { background: #CCC; }
            table tr:hover { background: #AAFFBF; }
            
            </style>
            Try this code for the table... :)

            Comment

            • lyodmichael
              New Member
              • Jul 2012
              • 75

              #7
              if you want to adjust you td width you need to adjust your table width,

              Comment

              Working...