Question:
Help with this HTML/CSS problem?
Shawn
2014-06-19 13:30:13 UTC
I'm taking this Tutorial at - http://thesiteslinger.com/blog/tutorial-how-to-code-your-psd-into-a-html-css-layout/

And I'm at the Beginning where you create a HTML and CSS file. I've created the .html and .css file as well as a "Images" folder which contains the background and when ever I load the .html file the background image doesn't load. Did they leave something out? Or is it my folder? I have all of these files inside a "Home" folder. I'm not understanding why the page isn't loading the background.

(CSS Code)
body, div, img, h1, h2, h3, h4, h5, h6, p,
ul, ol, li, dl, dd, dt, blockquote, fieldset,
legend, label, input, textarea { margin: 0; padding: 0; border: 0; }

h1, h2, h3, h4, h5, h6, p { margin: 0 0 1em 0; }

h1{font-size: 200%;}

h2{font-size: 170%;}

h3{font-size: 140%;}

h4{font-size: 110%;}

h5{font-size: 80%;}

h6{font-size: 50%;}

body { background-color:#D7D5C3;background-image:url(images/bg.jpg); }

#container { position:relative; margin:0 auto; width:960px; }

.header { height:139px; width:960px;}


(HTML Code)




Hit Machine Music


















Thanks in advance!
Four answers:
Chris
2014-06-19 14:57:00 UTC
The quotes don't matter at all here, what matters is capitalization though.

Is the folder called Images or images? Is the file called bg.jpg? Or is it Bg.jpg? Unless it matches exactly, it won't load.

And the path has to be right or course.

Your css file is "next to" the images folder, correct?
Franco
2014-06-19 19:21:08 UTC
If what you are showing is part of a tutorial, then the tutorial is 100% garbage. You have to make sure your picture's file name, and file extension matches the css file name, and file extension of the picture.



For example:



css - bg.jpg

picture - bg.jpg



If you want to use a folder called images, then you have to make sure you use the right css, so you can see your picture on your web page. If called your folder images in your css, then you have to do the same with your folder called images.



CSS:



body {

background-image: url("images/bg.jpg");

background-repeat: no-repeat;

}



HTML:









Hit Machine Music







You should learn from experts how to use DIV's.





Albert W
2014-06-19 20:33:07 UTC
Hi there,

Try this code to link your css stylesheet to your html page:



This worked for me.

Al
?
2014-06-19 14:07:16 UTC
body { background-color:#D7D5C3;

background-image:url('images/bg.jpg');

}



Note the addition of quotes around images/bg.jpg


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...