Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 8 of 8
  1. #1
    Member
    Join Date
    May 2004
    Posts
    76
    Member #
    5925
    I was comparing divs and tables, and I noticed that when you specify div and table widths they are exactly the same width, but when you add a border to it the two become different widths. Maybe I'm just doing something wrong. Is there a way to fix this, or is it just the way these two elements are supposed to be displayed?

    Here's a link:

    http://206.116.224.94:447/current/tabletest.html

  2.  

  3. #2
    Senior Member Fallout's Avatar
    Join Date
    Aug 2003
    Location
    Richmond, Virginia
    Posts
    543
    Member #
    2748
    When I droped the width from:
    Code:
    <table width="120" cellspacing="0" cellpadding="0" border="0">
    they then evened up.

  4. #3
    Member drews's Avatar
    Join Date
    Nov 2002
    Location
    St. Petersburg, Florida
    Posts
    63
    Member #
    341
    This is because when the border actually goes on the outside of the table. So when you specify a border the width doesn't start until after the left border and continues until the right border. Then the right border tacks on an extra width specified in the border="x" attribute.

    One way to overcome this is to use CSS. I have an example below.
    Code:
     <html>
    <head>
    <style type="text/css">
    <!--
    table {border: 2px solid #000; width: 100px;}
    div {border: 2px solid #000; width: 100px;}
    -->
    </style>
    </head>
    <body>
    <div>Div Test</div>
    <table cellspacing="0" cellpadding="0">
    <tr><td>Table Test</td></tr></table>
    </body>
    </html>
    Hope this helps.
    -drews
    -White Fiber Hosting - Coming Soon!

  5. #4
    Member
    Join Date
    May 2004
    Posts
    76
    Member #
    5925
    Your above code works for IE 6, but produces the same problem with mozilla, netscape, and firefox.

  6. #5
    Member drews's Avatar
    Join Date
    Nov 2002
    Location
    St. Petersburg, Florida
    Posts
    63
    Member #
    341
    Who cares about all those other meaningless browsers. :lick: I know, and I forgot to mention that I only tested it on IE. But hey, my solutions works for IE!
    -drews
    -White Fiber Hosting - Coming Soon!

  7. #6
    Senior Member Fallout's Avatar
    Join Date
    Aug 2003
    Location
    Richmond, Virginia
    Posts
    543
    Member #
    2748
    Your original code without the width property on the <table> tag looks fine in IE and Firefox PC.

  8. #7
    Member
    Join Date
    May 2004
    Posts
    76
    Member #
    5925
    Thanks for the solution Fallout. Weird how specifying the table size which is the size of the cell messes it up. Thanks again

  9. #8
    Senior Member Fallout's Avatar
    Join Date
    Aug 2003
    Location
    Richmond, Virginia
    Posts
    543
    Member #
    2748
    Your very welcome!


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 08:19 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com