Search code examples
htmlcssbackground-imageexternal

how to get background image present in other folder using css?


Guys this is my folder structure

Project

  • index.php
  • css

    style.css

  • js

    javascript.js

  • image

    background.jpeg

style.css

body{
background-image: url("image\background.jpeg");
}

index.php

<html>
<head>
    <title>Todo Application</title>
    <link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
    <div id = "header">
    hiuiiiii
    </div>
</body>
</html>

So guys tell me where am i wrong such that i can correct it so that my background image is displayed.


Solution

  • I believe this is the issue.

    Incorrect - url("image\background.jpeg");

    Correct - url("../image/background.jpg");

    ../ - This means one directory up to give the image location, as in your case, it is inside image directory.

    Hope this helps.