White sheet centered on gray background?

Discussion in 'CSS' started by TechnoGeek, May 6, 2009.

  1. #1
    Using this code:

    <body style="margin:0; background-color: #9f9f9f">
      <table width="768" border="0" cellspacing="0" cellpadding="3" bgcolor="#ffffff" align="center">
    Code (markup):
    I get a white sheet centered on a gray background.

    How do I achieve the same effect using CSS?

    Thanks in advance.
     
    TechnoGeek, May 6, 2009 IP
  2. Caden Grant

    Caden Grant Active Member

    Messages:
    294
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #2
    I'm not sure I completely understand what you're saying but I think you mean how do you transform that into CSS.

    In your CSS file or in the header of your site, whatever you use for styling, you would put..

    
    body { margin:0; background-color: #9f9f9f; }
    
    Code (markup):
    As for the table which you shouldn't use unless you're displaying data.. you just define an id or class for the table like:

    
    <table id="whateverhere" width="768" cellpadding="0" cellspacing="0">
    
    Code (markup):
    Then in your CSS put
    
    #whateverhere { background-color: #ffffff; margin: 0 auto; }
    
    Code (markup):
    I think that's how you center a table. Hope this helps.
     
    Caden Grant, May 6, 2009 IP
  3. TechnoGeek

    TechnoGeek Peon

    Messages:
    258
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks, Caden.
    Your solution did the trick.

    BODY {
      background-color: #9f9f9f;
      margin: 0;  
    }
    .wrapper {
      width: 760px;
      margin: 0 auto;
      border: 0;
      padding: 0;
      background-color: #FFFFFF;
    }
    
    Code (markup):
     
    TechnoGeek, May 6, 2009 IP
  4. Caden Grant

    Caden Grant Active Member

    Messages:
    294
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #4
    You're welcome. Glad I could help :)
     
    Caden Grant, May 6, 2009 IP