Joyster Posted November 12, 2007 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 Link to comment Share on other sites More sharing options...
Ingolme Posted November 12, 2007 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";} Link to comment Share on other sites More sharing options...
Joyster Posted November 12, 2007 Author 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 Link to comment Share on other sites More sharing options...
Ingolme Posted November 12, 2007 Share Posted November 12, 2007 Actually, you have to remove the quotes (") because they aren't needed in CSS. Link to comment Share on other sites More sharing options...
Joyster Posted November 12, 2007 Author Share Posted November 12, 2007 I need to validate this xhtml document first.I've found errors on it.Sorry for the inconvenience.Joyster Link to comment Share on other sites More sharing options...
Joyster Posted November 12, 2007 Author 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 Link to comment Share on other sites More sharing options...
Synook Posted November 14, 2007 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 Link to comment Share on other sites More sharing options...
Ingolme Posted November 14, 2007 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 Link to comment Share on other sites More sharing options...
justsomeguy Posted November 15, 2007 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"; Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.