Jump to content

Disappearing background colour


Recommended Posts

When I put in the !DOCTYPE for XHTML 1.0 Strict, the background colour disappears (goes from blue to white).Here's the code

<!DOCTYPE htmlPUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html><head><title>The Future of Humanity</title><style type="text/css">body {background-color: "#66ccff";}</style></head><body><!--This website is all about the Future of Humanity--><h1 align="center">The Future of Humanity</h1><h2>The Milky Way</h2><p><img src="MilkyWay.jpg" align="left">Our Galaxy, the Milky Way, is on a collision course with the next nearest Galaxy, Andromeda, and this is going to happen in about 1 Billion years.<br /></p><hr /></body></html>

Does anybody know why?Thanks, Joyster :)ps. same thing happens when I use XHTML 1.0 Transitional.I'm using IE7

Link to post
Share on other sites
In XHTML all styles have to be applied to both the html and body elements:html,body {background-color: "#66ccff";}
I tried that but am getting the same problem:-
<!DOCTYPE htmlPUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html><head><title>The Future of Humanity</title><style type="text/css">html,body {background-color: "#66ccff";}</style></head><body><!--This website is all about the Future of Humanity--><h1 align="center">The Future of Humanity</h1><h2>The Milky Way</h2><p><img src="future\MilkyWay.jpg" align="left">Our Galaxy, the Milky Way, is on a collision course with the next nearest Galaxy, Andromeda, and this is going to happen in about 1 Billion years.<br /></p></body></html>

Same with Transitional.Joyster

Link to post
Share on other sites

Well the problem is now solved:-Here's the solution:-

<!DOCTYPE htmlPUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252" /><title>The Future of Humanity</title><style type="text/css">html,body {background-color: #66ccff;}</style></head><body><!--This website is all about the Future of Humanity--><h1>The Future of Humanity</h1><h2>The Milky Way</h2><p><img src="future\MilkyWay.jpg" alt="Milky Way" />Our Galaxy, the Milky Way, is on a collision course with the next nearest Galaxy, Andromeda, and this is going to happen in about 1 Billion years.<br /></p></body></html>

Thanks for your help. Edit:- It seems the main problem was the " " around the #66ccff background colour!Joyster :)

Link to post
Share on other sites

Yes - the only place you need quotation marks, ever, in CSS is when defining URLs with spaces in them. Otherwise, if you hve quotation marks, take them out :)

Link to post
Share on other sites
Yes - the only place you need quotation marks, ever, in CSS is when defining URLs with spaces in them. Otherwise, if you hve quotation marks, take them out :)
Or if you're defining a font family with a space in it. Basically any value that includes a space should have quotes around it.font-family: Arial, Batman, "Times New Roman";
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...