Background Color Wont stay

Discussion in 'HTML & Website Design' started by Kngavl, Feb 7, 2008.

  1. #1
    Crazy annoying,
    <body bgcolor="2db6ef">
    I place that in the code and I also have an image code right after it. I preview the page and the background is the right color.
    However.
    If I add some text anywhere, when I preview the page the background turns to white.
    No idea whats causing this, there is no other code (other then the necessities).
     
    Kngavl, Feb 7, 2008 IP
  2. Kngavl

    Kngavl Peon

    Messages:
    964
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    0
    #2
    <style type="text/css">
    <!--
    body {
    background-color: #2db6ef;
    }
    -->
    </style>

    Post that in your head and thats your solution.
     
    Kngavl, Feb 7, 2008 IP
  3. walkere

    walkere Active Member

    Messages:
    112
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    58
    #3
    The problem may be with css styles.

    Most attribute tags (like bgcolor) are deprecated these days, and it's better practice to use a CSS stylesheet or inline styles (like style="bgcolor: #ffffff;".

    I'm not positive, but the problem you're getting may be from the way stylesheets cascade. If your browser has a default style of "bgcolor: white," then every element inherits that style. By changing the attribute of the body tag, you're not changing the style of any of the sub-elements.

    Long story short, use a css style like was already posted.
    - Walkere
     
    walkere, Feb 7, 2008 IP
  4. DHGate-Reality

    DHGate-Reality Peon

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hmm, that really necessary? I've never had such problems.
     
    DHGate-Reality, Feb 7, 2008 IP