Why isn't the page background image displayed?

The background color is there, it means style1.css is connected.

body { background-image: url(style/images/bg1.jpg); background-color: 51ff44; } <html> <head> <title> Repairing phones </title> <link rel="stylesheet" type="text/css" href="style/style1.css" /> </head> <body> </body> </html> 

style.css

index.html

But if you make the background in index.html, and not in style1.css, then everything works fine.

one

 <html> <head> <style> body { background-image: url(style/images/bg1.jpg); background-color: 51ff44; } </style> <title> Repairing phones </title> </head> <body> </body> </html> 

    1 answer 1

    Judging by the structure of your project, this happens because you are trying to connect the background image from different folders. Regarding index.html, the picture is in style/images/ , but relative to style1.css - in images/

    Therefore, you should specify the address in style1.css as follows:

     body { background-image: url(images/bg1.jpg); background-color: 51ff44; }