0

I have a file structure of:

home.html
img/bg_damask1.jpg
css/style.css

When I set my body background image I can't get it to load. I've tried:

background-image: url('../img/bg_damask1.jpg');
background-image: url('/img/bg_damask1.jpg');
background-image: url('img/bg_damask1.jpg');

But none are working. How do I get my css to reference the background image?

ETA: In browser dev tools I see that no matter what file path I put in, the browser is only referencing 'bg_damask1.jpg' without the file path. If I edit it in dev tools the image shows up using option #1. Now I'm stumped as to what's causing the breakdown.

2
  • The first method should work. Check in developer tools of your browser if any other rule overwrite this one. Commented Nov 4, 2015 at 0:52
  • also make background-size:cover Commented Nov 4, 2015 at 0:53

2 Answers 2

1

If you try to use for this body.

Your css must be like this

body {
    background-image: url(../img/bg_damsk1.jpg);
}

Also for you example is

body {
	background-image: url(http://www.radioviva.fm.br/images/backgrounds/bg-squares-3d.jpg);
}
<!DOCTYPE html>
<html>
<head>
	<title>Example</title>
</head>
<body>

</body>
</html>

That example you must just change url path to yours.

Sign up to request clarification or add additional context in comments.

Comments

0

Third option should be working, check the source code in your webbrowser and check if the image is actually found. If not try reuploading the image, renaming it or placing it in another folder.

1 Comment

if the OP's CSS is in style.css, the third option won't work.

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.