Joyster 0 Posted November 12, 2007 Report Share Posted November 12, 2007 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 Quote Link to post Share on other sites
Ingolme 1,035 Posted November 12, 2007 Report Share Posted November 12, 2007 In XHTML all styles have to be applied to both the html and body elements:html,body {background-color: "#66ccff";} Quote Link to post Share on other sites
Joyster 0 Posted November 12, 2007 Author Report Share Posted November 12, 2007 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 Quote Link to post Share on other sites
Ingolme 1,035 Posted November 12, 2007 Report Share Posted November 12, 2007 Actually, you have to remove the quotes (") because they aren't needed in CSS. Quote Link to post Share on other sites
Joyster 0 Posted November 12, 2007 Author Report Share Posted November 12, 2007 I need to validate this xhtml document first.I've found errors on it.Sorry for the inconvenience.Joyster Quote Link to post Share on other sites
Joyster 0 Posted November 12, 2007 Author Report Share Posted November 12, 2007 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 Quote Link to post Share on other sites
Synook 47 Posted November 14, 2007 Report Share Posted November 14, 2007 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 Quote Link to post Share on other sites
Ingolme 1,035 Posted November 14, 2007 Report Share Posted November 14, 2007 I don't think you need quotes for background URLs either. Take a look at this W3Schools example: http://w3schools.com/css/pr_background-image.asp Quote Link to post Share on other sites
justsomeguy 1,135 Posted November 15, 2007 Report Share Posted November 15, 2007 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"; Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.