0

I'm trying to use a photo ( that I copied the path from) to make my background image. I added an image earlier using the same method to copy the location and it's showing up.background-image:

it's turning blue in the parenthesis. I'm brand new and have no idea what to do. Any help would be greatly appreciated!

#body{
background-image: url(/Users/samanthagaiser/Basic_portfolio/assets/images/dot-grid.png);
}

when I "follow the link" in cs code it clicks over to the next window where I have the image saved.

3
  • You really should practice using relative referencing for things like images. A copy of the image should be in your project folder and referencing it should be like this. background-image: url("/images/dot-grid.png"); Commented Oct 4, 2019 at 22:59
  • Please @Samantha review stackoverflow.com/help/how-to-ask and try to create a real verifiable example. This has not data as your css or the link you call. We also don't know what is your current HTML editor. Please, try to improve the question to help us to help you Commented Oct 4, 2019 at 23:16
  • Possible duplicate of Can I use an image from my local file system as background in HTML? Commented Oct 4, 2019 at 23:18

1 Answer 1

0

Copy and paste image, .CSS file and .html file in one folder. Or if You have just .html file copy image to same folder as .html then change:

body{
    background-image: url('./dot-grid.png');
}

Path to image have to be relative to file where You load it.

Bellow examples:

No 1.

CSS:   /resources/css/styles.css  
Image: /resources/images/image.jpg

CSS in styles.css:

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

No 2.

CSS:   /resources/css/styles.css
Image: /resources/css/image.jpg

CSS in styles.css:

div { background-image: url('./image.jpg');
  1. ./ = look for image in same folder where .css file is.
  2. ../ = look for image below folder where .css file is.
  3. ../../ = loog for image two folders below .css file is.
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.