Results 1 to 16 of 16

Thread: HTML/CSS Getting that relative table to 0, 0

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140

    HTML/CSS Getting that relative table to 0, 0

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
      <head>
        <title>Test Page</title>
        <style type="text/css">
          body {
            background: #ff00ff;
            color: #000000;
            margin: 0px;
            border: 0px;
            padding: 0px;
            text-align: center;
          }
        </style>
      </head>
      <body>
        <table style="width: 100%; padding: 0px; margin: 0px;">
          <tr style="padding: 0px; margin: 0px;">
            <td style="color: white; background-color: black; margin: 0px; border: 0px;">Foo</td>
          </tr>
        </table>
      </body>
    </html>
    No matter how hard I try, there is still an ugly pink line around the edge of that little black box. Regardless of which browser I use. The problem is, I've seen this solved without absolute positioning. But the page it was one is a jumble of CSS and deprecated attributes, so I don't know which one is actually achieving the results.
    Travis, Kung Foo Journeyman
    As always, RTFM.

    WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
    Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    YBMS, but Mozilla doesn't.

  2. #2
    Addicted Member
    Join Date
    Nov 2001
    Location
    Yewston, Texis
    Posts
    240
    Well, if it's any consolation, if you set:

    background: #888888;

    The border is no longer pink, it's grey

    Seriously though, Why avoid absolute positioning? Another cheat would be to use a background image.

    cudabean

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140
    Because it has been done without absolute positioning. I have some old pages that I'm trying to update. They use a mix of deprecated attributes and bad CSS, and they get the effect I'm going for.

    I just can't figure out why it insists on having that border. I guess I could set a negative magin or padding.

    And the pages are white. The awful color was just so I knew the CSS was working. I just randomly toggled two of the nibbles.
    Travis, Kung Foo Journeyman
    As always, RTFM.

    WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
    Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    YBMS, but Mozilla doesn't.

  4. #4
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    Is the <html> tag a valid block per the specs? If so, it would have a default stylesheet per browser you'd have to override along with the <body> tag.
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  5. #5
    Fanatic Member Jerry Grant's Avatar
    Join Date
    Jul 2000
    Location
    Dorset, UK
    Posts
    810
    <table cellspacing="0">

    You need to set the cellspacing of your table to 0
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
      <head>
        <title>Test Page</title>
        <style type="text/css">
          body {
            background-color: #ff00ff;
            color: #000000;
            margin: 0px;
            border: 0px;
            padding: 0px;
            text-align: center;
          }
        </style>
      </head>
      <body>
        <table style="width: 100%; padding: 0px; margin: 0px" cellspacing="0">
          <tr style="padding: 0px; margin: 0px;">
            <td style="color: white; background-color: black; margin: 0px; border: 0px;">Foo</td>
          </tr>
        </table>
      </body>
    </html>
    Jerry Grant................tnarG yrreJ
    Website: <JG-Design></.net>
    Email: [email protected]
    Working towards a bug free world......
    (Not a Microsoft employee)

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140
    Interesting, so I looked.

    The html tag is part of the 4 standard, but it is an optional/optional tag. It is assumed after the DTD declaration that the whole document is an HTML (or XML) document. I can understand not using the tag, since gaving a grandparent tag is redundant, and confusing since it isn't part of the DOM.

    Setting the attributes in the CSS for the html tag didn't affect the page. Blah. Neither did removing the html tag (which I might do more often, I'm not sure).
    Travis, Kung Foo Journeyman
    As always, RTFM.

    WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
    Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    YBMS, but Mozilla doesn't.

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140

    RE: CellSpacing

    Yeap, that works. What a crock. I checked the HTML 4 specs. These attributes have not been deprecated. Odd, I assumed that they would be dismissed in favor of CSS. But you simply can't get the same affect in CSS. Why?

    I'm not sure if there was some design behind that, or oversight, or what. Blah.
    Travis, Kung Foo Journeyman
    As always, RTFM.

    WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
    Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    YBMS, but Mozilla doesn't.

  8. #8
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    It's the little known table CSS border-collapse!

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    	"http://www.w3.org/TR/html4/loose.dtd">
    <html>
      <head>
        <title>Test Page</title>
        <style type="text/css">
    	  html {
    	  	margin: 0px;
    	  	padding: 0px;
    	  }
    	  body {
    	  	background-color: blue;
    	  	color: #000000;
    	  	margin: 0px;
    	  	border: 0px;
    	  	padding: 0px;
    	  	text-align: center;
    	  }
    
    	  table {
    	  	width: 100%;
    	  	padding: 0px;
    	  	margin: 0px;
    	  	border-collapse : collapse;
    	  }
    	  tr {padding: 0px; margin: 0px;}
    	  td {color: white; background-color: black; margin: 0px; border: 0px;}
    </style>
      </head>
      <body>
        <table style="" >
          <tr style="">
            <td style="">Foo</td>
          </tr>
        </table>
      </body>
    </html>
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  9. #9

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140
    Rock on. I was playing with border-spacing but not getting the desired affect. I also was playing with the rules attribute of the table, which didn't have the desired affect in every browser. Border-collapse doesn't do anything for Communicator 4.79, but that is no great loss. It makes other browsers look consistent.
    Travis, Kung Foo Journeyman
    As always, RTFM.

    WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
    Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    YBMS, but Mozilla doesn't.

  10. #10
    WALDO
    Guest
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
      <head>
        <title>Test Page</title>
        <style type="text/css">
          body {
            background: #ff00ff;
            color: #000000;
            margin: 0px 0px 0px 0px;
            border: 0px 0px 0px 0px;
            padding: 0px 0px 0px 0px;
            text-align: center;
          }
        </style>
      </head>
      <body topmargin="0" leftmargin="0">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr style="padding: 0px; margin: 0px;">
            <td style="color: white; background-color: black">Foo</td>
          </tr>
        </table>
      </body>
    </html>

  11. #11
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    Umm...

    [nitpick]

    <body topmargin="0" leftmargin="0"> - This is not valid HTML, AFAIK.
    <table width="100%" border="0" cellspacing="0" cellpadding="0"> - This is depreciated, to be replaced with CSS...

    [/nitpick]
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  12. #12
    scoutt
    Guest
    Josh, or anybody for that matter, can you refresh my memory as to what the css equivelant is to that? mainly the margins?

  13. #13

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140
    There are sometimes a few ways to write the same thing in CSS. I'm not sure why there is the redundancy, but a very verbous way of replacing what Josh pointed out would be

    Code:
    <body style="margin-top: 0px; margin-left: 0px;">
    <table style="width: 100%; border-style: none; border-width: 0px;">
    I don't remember cell spacing and padding. You can set the margins and padding on the cells themselves, but there are models for the whole table, like collapsing borders, which will get a similar affect.

    As always, check the links in my sig.
    Travis, Kung Foo Journeyman
    As always, RTFM.

    WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
    Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    YBMS, but Mozilla doesn't.

  14. #14
    scoutt
    Guest
    thanks travis, and I have been to the links in your sig quiet a few times.

  15. #15
    scoutt
    Guest
    just out of curiosity, Travis, you wouldn't know what teh css for the body margins for NS4.xx, beside marginheight in the body tag.

    not that you would care or anything

  16. #16

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140
    No, not at all. If it doesn't support the standard (which I've found it doesn't), then I haven't a clue. I would hope that developer.netscape.com would have documentation, but I somehow imagine this has been shuffled under the rug.

    For the audience at home, that is the reason for a standard, so Travis only has to learn how to do it once, not once per browser.
    Travis, Kung Foo Journeyman
    As always, RTFM.

    WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
    Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    YBMS, but Mozilla doesn't.

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