SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member
    Join Date
    Aug 2003
    Location
    Maryland, USA
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    CSS width != Table width

    Hello.
    Do you know why CSS width and table width shows different in Netscape? for example, 750px of css is little longer than 750px of table width.

    How do I fix this? It is perfectly ok in IE..

    Thanks

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2002
    Location
    Bristol, UK
    Posts
    2,240
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have you got the padding attribute specified in your CSS? In the XHTML strict DTD, the padding is added on to the overall width of the DIV

    -Sam
    Sam Hastings

  3. #3
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by bobang

    How do I fix this? It is perfectly ok in IE..
    Wrong, IE is actually doing it incorrectly. Read this for more information.

  4. #4
    SitePoint Member
    Join Date
    Aug 2003
    Location
    Maryland, USA
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    omg..stupid me padding:4px...

    padding-top: 4px; padding-bottom:4px; fixed the problem

    Thanks

    hmm but somehow, it showed the same width on IE..

  5. #5
    SitePoint Member
    Join Date
    Aug 2003
    Location
    Maryland, USA
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So if I add 1px border to lets say 100px div, the total width will be 102px , not 100px?

  6. #6
    SitePoint Wizard
    Join Date
    Mar 2002
    Location
    Bristol, UK
    Posts
    2,240
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Bingo

    -Sam
    Sam Hastings

  7. #7
    Your Lord and Master, Foamy gold trophy Hierophant's Avatar
    Join Date
    Aug 1999
    Location
    Lancaster, Ca. USA
    Posts
    12,305
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by bobang
    So if I add 1px border to lets say 100px div, the total width will be 102px , not 100px?
    Yeah... Think of total width as:

    padding + margin + border + content

    When you specify a width for a DIV or a table, you are specifying content width.
    Wayne Luke
    ------------



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
  •