Newbie question

N

Nikolay Kurtov

I have index.html, style.css, image.png in one folder.

in index.html I include style.css
<head>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>


In style.css I set the background:

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


But the image doesn't load.
How should I correct the url in css?
 
J

John

Nikolay Kurtov said:
I have index.html, style.css, image.png in one folder.

in index.html I include style.css
<head>

<link href="style.css" rel="stylesheet" type="text/css" />
</head>


In style.css I set the background:

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


But the image doesn't load.
How should I correct the url in css?

Hi

Remove double primes around image.png

BODY { background-image:url(image.png);

Regards
John
 
D

dorayme

Nikolay Kurtov said:
I have index.html, style.css, image.png in one folder.

in index.html I include style.css
<head>

<link href="style.css" rel="stylesheet" type="text/css" />
</head>


In style.css I set the background:

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


But the image doesn't load.
How should I correct the url in css?

Perhaps you have made a spelling mistake or a space in the name,
case can be important including in the ".png"? Are you loading to
a free webhost? Try this on your local machine for your
index.html:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Newbie question</title>
<meta http-equiv="content-type" content="text/html;
charset=utf-8">

<style type="text/css">
body {background: #f00 url("image.png");
</style>

</head>
<body>

</body>
</html>

And see if you see red. Try a different image, one that
definitely opens when you drag the image file itself to the open
browser window.
 
M

mrcakey

Nikolay Kurtov said:
I have index.html, style.css, image.png in one folder.

in index.html I include style.css
<head>

<link href="style.css" rel="stylesheet" type="text/css" />
</head>


In style.css I set the background:

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


But the image doesn't load.
How should I correct the url in css?

Have you included <body> </body> tags in your HTML?

+mrcakey
 
M

mbstevens

Nikolay said:
I have index.html, style.css, image.png in one folder.

in index.html I include style.css
<head>
<title>Newbie question</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" /
<link href="style.css" rel="stylesheet" type="text/css" />
</head>


In style.css I set the background:

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


But the image doesn't load.
How should I correct the url in css?
In addition to the possibilities reflected in other answers, consider
whether you are posting from a Windows machine. Capitalization does not
matter there, but may on your server. For instance, IMAGE.PNG on a
windows machine would not load under a *[iu]x machine if you called it
"image.png".
 
M

mrcakey

rf said:
Body is an optional element in HTML.

In this case a URL is essential to solving the OP's problem.

But the picture he/she's hoping to display is specified in the CSS as a
background to the body.

+mrcakey
 
M

Michael Fesser

..oO(mrcakey)
But the picture he/she's hoping to display is specified in the CSS as a
background to the body.

The 'body' element is always there, even if it's not explicitly
mentioned in the HTML source code. Like 'tbody' for example.

Micha
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top