Not able to include back-ground image

body { background-image: url("C:\Users\lalit kumar\Desktop\HTML Document\LALIT_PHOTO2"); } This is a heading

This is a red paragraph

H2O is the formula of water and superscript

Probably the culprit is the path. This may work if you are on a development machine locally but the image has to go somewhere where the webserver can link to it

hi @lalitkumarji195

why there is no image file type, like .jpeg, .png, .gif etc at your image file?

This is .jpg file and I have tried also with .jpg extension still it is not working .

you can try this way, right click on the image>>open with…>> (open it with any of your browser)>>then copy the url from the browser and paste it to your url code.

and if your index file is and the photo is in the same folder, you can try like this…


I’m assuming that you are using codepen. On online tools like codepen to use an image ,it should be hosted somewhere on the web to display them. Try putting the file somewhere online and then put the link inside the url(); I hope it will work :grin:

Edit: You can use to host image

I am not using codepen .I am using notepad and image is placed on my local desktop system .

Oh Great , Thanks Now It works . Please also tell me the reason that how ./LALIT_PHOTO.jpg works

1 Like

./ it looks for any file in the same folder

Thank you , It was really Nice . I am going to log out now .But Next time When I will face a problem .How can I find you on this forum .

1 Like

You also need to know why this does not work. for using a full path you need to follow the other option I mentioned above.

Well, if you want me to here, just include my name at the end your content like this @lalitkumarji195 just type @thetradecoder

ok , fine sir . Good Night

1 Like

@lalitkumarji195 Have a sweet dream!