1. This website uses cookies. By continuing to use this website you are giving consent to cookies being used.
    For information on cookies and how you can disable them visit our Cookie Usage page.
    Dismiss Notice

CSS background color CSS?

Discussion in 'Web Development' started by jrodrick4, Dec 31, 2009.

  1. jrodrick4

    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

    Mimoun Administrator Staff Member Director Verified Member

    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

    Mimoun Administrator Staff Member Director Verified Member

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