Search code examples
cssimagelocal-files

load image from pc on a local website css


I am making a website only for usage as a local '.html' file which I can open in Chrome and in that file I am trying to reference an image at

"file:///C:\Pictures\BG.png"

to make it the document's background, but it won't work. I think I may need something such as: src("file:///C:\Pictures\BG.png")

although that isn't working either what do I need and here is the piece of my css referencing it:

body{background-color: #000; background-image: 'file:///C:\Pictures\BG.png';} (I indented it)


Solution

  • Keep your images in the same folder that you HTML file, this will make easier to work with images. Then you just have to add the property.

    body { background-image: url(“myimage.jpg”);
    

    }