+ 2

What am I doing wrong with this image?

Iā€™m trying to use an image as my background and the code is as follows (CSS): body { background-image: url(ā€œhttps://goo.gl/images/VQCSBkā€); background-repeat: no-repeat; } Whenever I run there is still just a blank background. Help

12th Jun 2018, 10:46 PM
Tence Sailor
Tence Sailor - avatar
13 Answers
+ 2
It seems that the reason why the image isn't displaying is because the link doesn't exactly lead anywhere. When including URLs to images in HTML or CSS, you would need to provide a link that leads directly to your image, which could be done by right clicking (or long pressing on mobile) on the image and pressing "view image in new tab".
12th Jun 2018, 11:02 PM
Faisal
Faisal - avatar
+ 1
you were right faisal. thanks
13th Jun 2018, 12:31 AM
Tence Sailor
Tence Sailor - avatar
0
I think these too.
12th Jun 2018, 11:42 PM
Alan CarreƱo Fiestas
Alan CarreƱo Fiestas - avatar
0
what if I want to use an image in my /root folder?
25th Jun 2018, 10:05 PM
Nicholas Johnson
Nicholas Johnson - avatar
0
Nicholas Johnson , you can simply define the local path. for example, <img src="/root/test.jpg" alt=""> but as a best practice,I would recommend that you create a specific folder for images so that later on, it'll be easier for you to attach your images into the webpage.
26th Jun 2018, 10:47 PM
arif asyraf
arif asyraf - avatar
0
arif asyraf I found that when i put the images in their own folder they won't load unless my html document is saved in the same folder as the images. but I want to add a background image using html and not have to call in a stylesheet
26th Jun 2018, 10:51 PM
Nicholas Johnson
Nicholas Johnson - avatar
0
Nicholas Johnson have you specified the image source correctly? usually, i will create one folder for a project and then create the subsequent folders for them like img,js,css and all accordingly. for your question, you can try this, <body style="background-image:url(/root/test.jpg)"> </body> I'm not sure if this is correct because I haven't done it this way for a long time. I encourage you however to use stylesheet so that your code look cleaner.
26th Jun 2018, 11:08 PM
arif asyraf
arif asyraf - avatar
0
arif asyraf thank you for your reply, I appreciate it. also where does the last double quote go in your code you wrote?
26th Jun 2018, 11:10 PM
Nicholas Johnson
Nicholas Johnson - avatar
0
Nicholas Johnson oh, silly me. Thank you for pointing that out, I missed it. edited the answer.
26th Jun 2018, 11:12 PM
arif asyraf
arif asyraf - avatar
0
arif asyraf no problem. yea, code didn't work. oh well, CSS it is lol
26th Jun 2018, 11:20 PM
Nicholas Johnson
Nicholas Johnson - avatar
0
Nicholas Johnson yea, sorry about that. CSS will be fun. I'd recommend you to look into SASS once you're done with css for a more entertaining experience with CSS. Happy coding, my friend šŸ˜
26th Jun 2018, 11:25 PM
arif asyraf
arif asyraf - avatar
0
thank you again my friend.
26th Jun 2018, 11:26 PM
Nicholas Johnson
Nicholas Johnson - avatar