Jump to content

CSS Background Color


Spe92002
 Share

Recommended Posts

Hey, I am new to css and I am having a little trouble apply background color to my page. Thats my css code right now for my page and it says every background color will be gray. However, I am using internet explorer, firefox, and safari, and it is not showing the background in gray, it shows it in white. Thanks in advance! Here is my code:body { font-family: verdana, arial, serif; background: #CCCCCC; font-size: 10pt; margin-top: 0; margin-bottom: 0; margin-left: 0; margin-right: 0; padding-left: 0; padding-right: 0;}}#header { background: #CCCCCC; margin: 20px; padding: 10px; height: 100px;}#left { background: #CCCCCC; position: absolute; left: 15px; top: 160px; width: 200px;}#center { background: #CCCCCC; top: 0; margin-left: 230px; margin-right: 15px;}h1 {font-family: verdana, arial, serif; font-size: 18pt;font-weight: lighter; }

Link to comment
Share on other sites

If your only going to set the background color, then the best bet would be to use "background-color" tag instead of "background".When I use the "background" tag I always define everything, such as "background: #CCC none repeat scroll 0%;"You can get more information at http://www.w3schools.com/css/css_background.asp

Link to comment
Share on other sites

Let me fix this up for you. The most probable reason that it wasn't working was that you had two closing braces after the body CSS.Aside from that, in certaindoctypes applying CSS only to the body won't work, you have to add it to the html element too. You don't need to assign the same background color to all the elements.

html,body {font-family: verdana, arial, serif;background-color: #CCCCCC;font-size: 10pt;margin: 0;padding: 0;}#header {margin: 20px;padding: 10px;height: 100px;}#left {position: absolute;left: 15px;top: 160px;width: 200px;}#center {margin-left: 230px;margin-right: 15px;}h1 {font-family: verdana, arial, serif;font-size: 18pt;font-weight: lighter;}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...