Login or Sign up Help | Site Map
Connecting Tech Pros Worldwide

Add a background Image

Question posted by: infoseekar (Newbie) on March 28th, 2008 05:05 PM
Hi

I want to have a background image on one of my php page. I have no idea how to do it since i am still a beginner.

I have found this code but this does not work.
Code: ( text )
  1. <html>
  2. <head>
  3.  
  4. <style type="text/css">
  5. body {background-image: url(1.jpg);}
  6. </style>
  7.  
  8.  
  9. </head>
  10. </html>

thanks
Would you like to answer this question?
Sign up for a free account, or Login (if you're already a member).
ronverdonk's Avatar
ronverdonk
Moderator
4,138 Posts
March 28th, 2008
05:14 PM
#2

Re: Add a background Image
What do you mean by 'it does not work'? What does not work?
Do you have the image in the correct path? Does it even exist? If so it works.

Ronald
__________________
RTFM is an almost extinct art form.

Reply
hsriat's Avatar
hsriat
Expert
1,305 Posts
March 28th, 2008
05:15 PM
#3

Re: Add a background Image
Quote:
Originally Posted by infoseekar
Hi

I want to have a background image on one of my php page. I have no idea how to do it since i am still a beginner.

I have found this code but this does not work.
Code: ( text )
  1. <html>
  2. <head>
  3.  
  4. <style type="text/css">
  5. body {background-image: url(1.jpg);}
  6. </style>
  7.  
  8.  
  9. </head>
  10. </html>

thanks
See these examples:
With CSS background
With Background Attribute

Reply
infoseekar's Avatar
infoseekar
Newbie
31 Posts
March 28th, 2008
06:13 PM
#4

Re: Add a background Image
Quote:
Originally Posted by ronverdonk
What do you mean by 'it does not work'? What does not work?
Do you have the image in the correct path? Does it even exist? If so it works.

Ronald


Sorry, What i meant, nothing appear on display just a white black screen. The .html file and jpg file are in the same directory.

thanks

Reply
hsriat's Avatar
hsriat
Expert
1,305 Posts
March 28th, 2008
06:53 PM
#5

Re: Add a background Image
Where's the body tag?

Reply
ronverdonk's Avatar
ronverdonk
Moderator
4,138 Posts
March 28th, 2008
07:07 PM
#6

Re: Add a background Image
Quote:
Originally Posted by hsriat
Where's the body tag?
Doesn't really matter with FF 2 or IE 7. Both display the background image in these browsers without the <body> tag.

Ronald
__________________
RTFM is an almost extinct art form.

Reply
markusn00b's Avatar
markusn00b
Expert
1,743 Posts
March 28th, 2008
07:17 PM
#7

Re: Add a background Image
Quote:
Originally Posted by infoseekar
Sorry, What i meant, nothing appear on display just a white black screen. The .html file and jpg file are in the same directory.

thanks


If this is a html file, why is this question being asked in the php forum?

Reply
ronverdonk's Avatar
ronverdonk
Moderator
4,138 Posts
March 28th, 2008
07:19 PM
#8

Re: Add a background Image
Quote:
Originally Posted by markusn00b
If this is a html file, why is this question being asked in the php forum?
You are soooo right markus. But we all let it slip, so let it go.

Ronald

Reply
hsriat's Avatar
hsriat
Expert
1,305 Posts
March 28th, 2008
07:58 PM
#9

Re: Add a background Image
Quote:
Originally Posted by ronverdonk
Doesn't really matter with FF 2 or IE 7. Both display the background image in these browsers without the <body> tag.

Ronald

Ok, that's fine. I never tried anything like that.
:)

Quote:
Originally Posted by markusn00b
If this is a html file, why is this question being asked in the php forum?

We have to solve this...! Else it would be a shame for we PHP guys, that we couldn't even solve a simple HTML problem. ;)

Regards

Reply
ronverdonk's Avatar
ronverdonk
Moderator
4,138 Posts
March 28th, 2008
10:42 PM
#10

Re: Add a background Image
Quote:
Originally Posted by hsriat
Ok, that's fine. I never tried anything like that.
:)
We have to solve this...! Else it would be a shame for we PHP guys, that we couldn't even solve a simple HTML problem. ;)

Regards
I agree, we started it, we finish it.
As for my remark, I could only test in FF2 and IE7, but maybe OP has an old brwoser where that does not work at all.

So you suggestion to include a <body> tag in the code looks like a good place to start, just to eliminate any irregularity in the code.

ROnald

Reply
media3000anthony's Avatar
media3000anthony
Newbie
4 Posts
March 30th, 2008
11:46 AM
#11

Re: Add a background Image
Hello infoseekar,

I once had this problem.
It took me ages to solve.
Maybe this is the solution for you.

What happened:

I saved a png image file from a website, but stupidly saved it as .jpg

When I came to use the image as a background:
  • Firefox showed it just fine
  • Internet explorer would not show it, no matter what I did

The solution was to re-save the image (from the original website) as a png and use image software to convert it to a jpg.

I have re-created this problem just now using Firefox 2.0.0 and IE 6.0
They gave the same result as described above

ps I love this website: w3schools CSS tutorial

Regards,
Anthony

[signature removed] moderator

Reply
infoseekar's Avatar
infoseekar
Newbie
31 Posts
March 31st, 2008
09:00 AM
#12

Re: Add a background Image
Quote:
Originally Posted by media3000anthony
Hello infoseekar,

I once had this problem.
It took me ages to solve.
Maybe this is the solution for you.

What happened:

I saved a png image file from a website, but stupidly saved it as .jpg

When I came to use the image as a background:
  • Firefox showed it just fine
  • Internet explorer would not show it, no matter what I did

The solution was to re-save the image (from the original website) as a png and use image software to convert it to a jpg.

I have re-created this problem just now using Firefox 2.0.0 and IE 6.0
They gave the same result as described above

ps I love this website: w3schools CSS tutorial

Regards,
Anthony

[signature removed] moderator


PROBLEM SOLVED:: Thanks all of you.. sorry for posting this question in wrong forum.

regards

Infoseekar

Reply
ronverdonk's Avatar
ronverdonk
Moderator
4,138 Posts
March 31st, 2008
09:04 AM
#13

Re: Add a background Image
Quote:
Originally Posted by infoseekar
PROBLEM SOLVED:: Thanks all of you.. sorry for posting this question in wrong forum.

regards

Infoseekar
That's okay. As long as you are helped.See you around.

Ronald

Reply
Reply
Not the answer you were looking for? Post your question . . .
169,969 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Top PHP Forum Contributors