background color CSS?

Discussion in 'HTML - XHTML - CSS' started by jrodrick4, Dec 31, 2009.

  1. jrodrick4 New Member

    Please guide me
    How i change background color through CSS?
    I mean what should i write as a CSS code in .css file
  2. You should use the background property and the color value that you want as your color. For example:

    body { background:#red; }

    This css code will give your page the color of red. Another example is:

    p { background:#blue; }

    This css code will give your paragraphs the background color of blue.
  3. Mimoun Administrator

    When using the color name don't put the # before it.
    Only place the # when using the RGB color codes:
    Code:
    body { background-color: red; }
    With RGB color code:
    Code:
    body { background-color: #FF0000; }
    or shorthand:
    Code:
    body { background: red; }
    With RGB color code:
    Code:
    body { background: #F00; }
  4. Mimoun, you are right that the pound sign (#) should not be included in the value in these cases. It was a mistake on my part :(
  5. Mimoun Administrator

    I made the mistake myself ones that is why I noticed it.