Hi I am a newbie with basic understanding of css and html, but i just cant understand why the background image wont display. i tried different images (gif,png,jpeg) etc. I have tried by keeping image in same folder as css stylesheet, by keeping image in images folder and giving proper the proper path for example 'images/image.gif' , but nothing works... Have attached html code, css (style.txt 'please note it is txt extension only because i was not allowed to upload it as css' , my local copy is style.css) and image. Please point out as to where i am making the mistake. Thanks in advance
no i dont have it online .... but i have uploaded the concerned files.... (i have noticed tht the image i hv uploaded is not the same one used in the css file... it should be.... background-image:url(image.gif) no-repeat; )
This is one HUGE error in your css : background-image:url('lion.jpeg') no-repeat; - You cannot apply the "no-repeat" property if you've put background-image before. This is the primary cause of the error. Valid format : background: url(lion.jpeg) no-repeat; or background-image: url(lion.jpeg); background-repeat: no-repeat; As you can see, I didn't put the apostrophes (" ' "). You shouldn't put them either. Hope it helps!
hi wiicker95 thanks for the tip, but the image is still not displaying. m still stuck.... i have made the image in photoshop... has it something to do with it ????
First test with the css in header and image in same directory as the html file and then go from there.
hi thanks cosx... it works if i keep image and html in same folder.... but it fails if i keep image in different folder say 'images' and i give path in css as 'images/image.gif'.... can u please tell me why ????
it did not work i put 3 dots... does it have to be ... (3 dots) before /images/image.gif is apostrophe needed ??
In this case it's a quotation mark, and no, you musn't put it. Dots won't work either... :/ What I can suggest is rewriting the whole thing, your CSS is invalid to begin with.
Did you managed to figure it out? You should l look up relative paths on gogle and also check w3schools.com for each and every css styling line. My advice, if you are just learning things, keep directory structure simple: /index.html => <LINK REL=StyleSheet HREF="css/style.css" TYPE="text/css"> /css/style.css => background:#fff url(images/image.jpg) no-repeat; /images/image.jpg
hi thanks for the tip... but it is not working.. i did all of the above... but "image.jpg" from a folder "images" does not display.... if image is kept in same folder as html then only it works... so frustrated... error is likely to be simple.. just cant figure it out...