I’m a beginner programmer and have looked at several resources, but I can’t figure out why location of a external css stylesheet matters. For example, changing the link to the file and the location of the file, respectively, will determine if a picture loads or not:
A simple line in the css:
body {
background: url(./images/test.jpg) center center fixed no-repeat;
}
This will load a picture:
<link rel="stylesheet" href="style.css" type="text/css" charset="utf-8" />
This will not:
<link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
Why?
Its because there is no
imagesfolder inside yourcssfolder. It’s relative to thecssfile, not thehtmlfile.You can fix it like so:
This goes up to the root directory first, then into the images folder.
Then you can use your css line: