Paul Verizer Posted February 26, 2014 Share Posted February 26, 2014 I'm trying to learn CSS and am using the w3 tuts. However, I can't seem to get my background image to show up. I can color the bg, but can't figure out what's wrong with my code or image location. The rest of the CSS is working. Thanks for looking. Root folder contains "index.html" and the image, "levitating_maus.jpg" <!DOCTYPE html><html><head><style>body {background-image:url("levitating_maus.jpg");}h1{color:orange;text-align:center;}p{font-family:"Times New Roman";font-size:20px;}</style></head><body><h1>CSS example!</h1><p>This is a paragraph.</p></body></html> Link to comment Share on other sites More sharing options...
Paul Verizer Posted February 26, 2014 Author Share Posted February 26, 2014 (edited) OK, put the image in a folder and changed the style code to this: <style>body {background-image:url("images/levitating_maus.jpg");}</style> and it works. However, when I move the CSS to an external stylesheet located in the root, the image doesn't show... HTML: <!DOCTYPE html><html><head><link rel="stylesheet" type="text/css" href="mystyle.css"></head><body><h1>Hello World!</h1></body></html> External CSS: <style>body {background-image:url("images/levitating_maus.jpg");}</style> Thanks for looking... Edited February 26, 2014 by Paul Verizer Link to comment Share on other sites More sharing options...
davej Posted February 26, 2014 Share Posted February 26, 2014 (edited) You have to be very careful with case-sensitivity on Linux servers. Also sometimes a leading ./ on the path seems to help it find an item in the current directory. Edited February 26, 2014 by davej Link to comment Share on other sites More sharing options...
dsonesuk Posted February 26, 2014 Share Posted February 26, 2014 <style>body {background-image:url("images/levitating_maus.jpg");}</style> IS this typo error? you would not have style tags in a external css document Link to comment Share on other sites More sharing options...
Paul Verizer Posted February 26, 2014 Author Share Posted February 26, 2014 IS this typo error? you would not have style tags in a external css document Not a typo error. JUST AN ERROR! That seems to have fixed it. I guess the html was looking past the style tags for the selectors and declarations I put in the css, but not for the background image. Anyway, now on to bigger and better mistakes. Thanks, posters. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now