Add a background Image

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • infoseekar
    New Member
    • Mar 2008
    • 34

    Add a background Image

    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=html]

    <html>
    <head>

    <style type="text/css">
    body {background-image: url(1.jpg);}
    </style>


    </head>
    </html>
    [/code]
    thanks
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    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

    Comment

    • hsriat
      Recognized Expert Top Contributor
      • Jan 2008
      • 1653

      #3
      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=html]

      <html>
      <head>

      <style type="text/css">
      body {background-image: url(1.jpg);}
      </style>


      </head>
      </html>
      [/code]
      thanks
      See these examples:
      With CSS background
      With Background Attribute

      Comment

      • infoseekar
        New Member
        • Mar 2008
        • 34

        #4
        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

        Comment

        • hsriat
          Recognized Expert Top Contributor
          • Jan 2008
          • 1653

          #5
          Where's the body tag?

          Comment

          • ronverdonk
            Recognized Expert Specialist
            • Jul 2006
            • 4259

            #6
            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

            Comment

            • Markus
              Recognized Expert Expert
              • Jun 2007
              • 6092

              #7
              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?

              Comment

              • ronverdonk
                Recognized Expert Specialist
                • Jul 2006
                • 4259

                #8
                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

                Comment

                • hsriat
                  Recognized Expert Top Contributor
                  • Jan 2008
                  • 1653

                  #9
                  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.
                  :)

                  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

                  Comment

                  • ronverdonk
                    Recognized Expert Specialist
                    • Jul 2006
                    • 4259

                    #10
                    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

                    Comment

                    • media3000anthony
                      New Member
                      • Mar 2008
                      • 4

                      #11
                      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

                      Comment

                      • infoseekar
                        New Member
                        • Mar 2008
                        • 34

                        #12
                        Originally posted by media3000anthon y
                        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

                        Comment

                        • ronverdonk
                          Recognized Expert Specialist
                          • Jul 2006
                          • 4259

                          #13
                          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

                          Comment

                          Working...