javi
javi

Reputation: 91

why won't my image show?

My image is saved in the same folder tree or whatever that is called as my webpage, and it won't load. It's probably something really simple but I can't figure it out. Any hint would be appreciated.

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML     4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <meta content="text/html; charset=ISO-8859-1"
    http-equiv="content-type">
    <title>website</title>
    <style type="text/css" media="screen, print, projection">

    body{
         background-image:url('C:\Users\blah\Desktop\webdesign\randompicture.png');
    }


    </style> 
    </head>
    <body>
    </body>
    </html>

Upvotes: 1

Views: 1560

Answers (3)

Nikhil Bhandari
Nikhil Bhandari

Reputation: 1584

instead of C:\Users\blah\Desktop\webdesign\randompicture.png'

use relative path if your htm file is in webdesign folder randompicture.png

use background-image: url(randompicture.png);

if the html file is on desktop

use background-image: url('./webdesign/randompicture.png');

Upvotes: 3

Rhapsody
Rhapsody

Reputation: 6077

if the image is in the same folder, use:

body
{
   background-image: url('randompicture.png');
}

Upvotes: 1

kapa
kapa

Reputation: 78741

Try using relative paths, if your picture is in the same directory as your html file, simply write:

background-image: url(randompicture.png);

Also, you don't need apostrophes in the url() notation of CSS.

If you put your rules into a separate CSS file, the path should be relative to the CSS file, not the HTML.

Upvotes: 1

Related Questions