1

This is probably a really simple problem that I'm guessing has a very obvious but stupid solution but I am not seeing it. I am trying to get an image to become a tiled background and for some reason the image is not appearing nor am I getting errors. I have checked permissions and set all files and folders to 777. Can someone point out the problem for me thanks.

My CSS file:

body {
    background-image: url("images/main_background.png");
}

My HTML file:

<!DOCTYPE html>
<html>

    <head>
        <title></title>
        <link rel="stylesheet" type="text/css" href="css/layout.css">
    </head>

<body>

    <div id="main_container">

    </div>

</body>

</html>
1
  • It might be the reason that the image isn't found in the directory/your are providing wrong url/the styleshet isn't found. Commented Nov 17, 2013 at 4:44

1 Answer 1

3

Your image is in images folder and css is in css folder.

images/main_background.png means that images folder is inside the css folder, but it is not.

write this:

body {
    background-image: url("../images/main_background.png"); 
}

OR

body {
    background-image: url("/images/main_background.png"); 
}
Sign up to request clarification or add additional context in comments.

2 Comments

Wow that was dumb of me I've been scratching my head for a half hour screwing with this problem. Thanks I would have thought chromes inspector would have given me a file not found error but I wasn't getting one
Welcome.. checking console is the best way to understand errors.

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.