Click to See Complete Forum and Search --> : rEFERENCING A BACKGROUND IMAGE ON YOUR OWN HD
RUNEMASTER
09-21-2005, 07:49 PM
If I can perform this miracle Ill be most content.
I just want to reference any image on my hard drive so it can serve as a background for my html document.
I tried the following, but nothing happened.
Ex:
<body background=C:\Documents and Settings\NA\My Documents\My Pictures>
<p><h1> <font COLOR="red"> Rudys Page </font></h1></p>
</body>
I get the large Rudys page, but no background image.
Whats wrong with the way Im referencing the image? Or is it that i have not saved the document as an html file yet?
David Harrison
09-21-2005, 07:52 PM
Well you've not actually referenced an image at all, you've just referenced a folder.
If you've not saved as a .html file yet, what exactly have you got it saved as?
JPnyc
09-21-2005, 07:52 PM
All attribute values should be in "", and yes it must be saved as an HTML doc. You realize that the pic would only show while on your pc?
RUNEMASTER
09-21-2005, 08:08 PM
Thanks guys.Yes, actually i saved it as an .html file in the same folder as the jpeg image. Thanks for pointing out the lack of actual image reference.
I altered the document, but still I get no background image.Heres the new doc.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Rudys Website</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body background="pd3.jpeg">
<p><h1> <font COLOR="red"> Rudys Page </font></h1></p>
</body>
</html>
David Harrison
09-21-2005, 08:23 PM
When referenceing files use forward slashes.
Before a folder path, you can put any of the following:
/ = the root folder (in this case that would be your C:)
./ = the current folder
../ = the parent folder (ie: the one further up the folder tree)
So basically, remove that slash, or replace it with ./ and it will work.
Joe, for HTML attribute values don't need to be quoted, on the other hand it is required for XHTML. However yeah, it's considered good practice to quote attribute values using double quotes.
Oh by the way RUNEMASTER, putting a header insde a paragraph is invalid and semantically incorrect since it cannot be both a header and a paragraph at the same time.
JPnyc
09-21-2005, 08:25 PM
You sure it's a jpeg extension and not jpg?
JPnyc
09-21-2005, 08:33 PM
It should still find it, Dave, even without the ./ Local addressing isn't usually that fussy.
David Harrison
09-21-2005, 09:05 PM
But the \ is the same as /, so it's looking for C:\pd3.jpeg instead of C:\Documents and Settings\NA\My Documents\My Pictures\pd3.jpeg
JPnyc
09-21-2005, 09:07 PM
But if you just put the file name and nothing else, if it's in the same folder, it should find it. Has to be a problem with the file name.
RUNEMASTER
09-21-2005, 09:16 PM
It worked after I changed teh jpeg to jpg.Though I had put jpeg in there cause when I right clicked on the image-the image property would read jpeg.
Great info on the slashes David.The image is now tiled in the background.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Rudys Website</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body background="./pd3.jpg">
<p><h1> <font COLOR="red"> Rudys Page </font></h1></p>
</body>
</html>
David Harrison
09-21-2005, 09:20 PM
As I'm sure Ms. Castro will soon reveal to you, you can use CSS to set a background, and have much more control over it. If you can't wait to read that far though, take a look here (http://www.w3.org/TR/CSS1#color-and-background-properties).
RUNEMASTER
09-21-2005, 09:29 PM
Yes thanks.Sadly Im still not finished reading the entire Html book.Though I am studying Css by lynda.com CD.Im learning both.Dear me.Thanks again. :o
ray326
09-21-2005, 10:13 PM
Hopefully Ms. Castro will also soon reveal the deprecated body attributes.