Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Background image won't show in HTML Google

I put a background url in my CSS inside body and connected the CSS file to the html file, but nothing shows on google. I’m 100% sure I have the right path to the image. But the image is in the path I coded and I have no clue why it says file not found.

body  {
    background-image: url("/CSS/Images/barcelonastadium.jpg");
  } 

GET file:///C:/CSS/Images/barcelonastadium.jpg net::ERR_FILE_NOT_FOUND

That error shows in console log even tho the file exists.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

HTML Code:

<!DOCTYPE html>
<html>
<head>
    <meta charset='utf-8'>
    <meta http-equiv='X-UA-Compatible' content='IE=edge'>
    <title> Barcelona </title>
    <meta name='viewport' content='width=device-width, initial-scale=1'>
    <link rel='stylesheet' type='text/css' media='screen' href='./CSS/home.css'>
</head>
<style>

</style>
<body>
    <h1> Barcelona </h1>
</body>
</html>

folder

>Solution :

Your file path as seen in GET file:///C:/CSS/Images/barcelonastadium.jpg net::ERR_FILE_NOT_FOUND has two protocols in it: file and C. You should use a relative path in your CSS file instead, to avoid the confusion:

./CSS/Images/barcelonastadium.jpg or ./Images/barcelonastadium.jpg

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading