Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. Background-image not working in external stylesheet

Background-image not working in external stylesheet

Scheduled Pinned Locked Moved Web Development
htmlcssdocker
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    swornavidhya_m
    wrote on last edited by
    #1

    I'm trying to create a tableless website. When using external stylesheet, the background-image property alone is not working with my external stylesheet. Other properties are working fine with the external stylesheet. I'm getting fuzzed to continue. My external stylesheet (style.css) and is placed in folder 'css' code is: The image is in folder 'images'. When surfng the google with 'background-image not working in external stylesheet' i found that if we place css in different folder and made a call for an image in differnt folder we've to give mention as

    background-image:url("../images/disdat-gold-red.gif");

    - even this failed. Again when searched, i found that instead of saying 'background-image' give code as follows for which they answered it worked fine. And the code is:

    background: #000000 url(images/disdat-gold-red.gif) repeat-x;

    - even this get failed for me. I'm attaching my html file along with my css file. Coding part in "style.css" #header { text-align:center; font-family:arial, verdana, 'times new roman'; font-size:15pt; font-weight:bold; color:#0ac0af; padding:2% 0 15% 0; background:url(images/disdat-gold-red.gif) no-repeat; } HTML code is: <html> <head> <meta name="GENERATOR" content="Microsoft FrontPage 6.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>Try Web Page</title> <link type=text/css rel=stylesheet href=css/style.css> </head> <body> <div id="container"> <div id="top"> <div id="header">Inside Header Top Container</div> <div id="nav">Inside Nav Top Container</div> </div> <div id="main"> <div id="left">Inside Left Main Container</div> <div id="right">Inside Right Main Container</div> </div> <div id="footer">Inside footer Container</div> </div> </body> </html>

    M.Sworna Vidhya

    L T 2 Replies Last reply
    0
    • S swornavidhya_m

      I'm trying to create a tableless website. When using external stylesheet, the background-image property alone is not working with my external stylesheet. Other properties are working fine with the external stylesheet. I'm getting fuzzed to continue. My external stylesheet (style.css) and is placed in folder 'css' code is: The image is in folder 'images'. When surfng the google with 'background-image not working in external stylesheet' i found that if we place css in different folder and made a call for an image in differnt folder we've to give mention as

      background-image:url("../images/disdat-gold-red.gif");

      - even this failed. Again when searched, i found that instead of saying 'background-image' give code as follows for which they answered it worked fine. And the code is:

      background: #000000 url(images/disdat-gold-red.gif) repeat-x;

      - even this get failed for me. I'm attaching my html file along with my css file. Coding part in "style.css" #header { text-align:center; font-family:arial, verdana, 'times new roman'; font-size:15pt; font-weight:bold; color:#0ac0af; padding:2% 0 15% 0; background:url(images/disdat-gold-red.gif) no-repeat; } HTML code is: <html> <head> <meta name="GENERATOR" content="Microsoft FrontPage 6.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>Try Web Page</title> <link type=text/css rel=stylesheet href=css/style.css> </head> <body> <div id="container"> <div id="top"> <div id="header">Inside Header Top Container</div> <div id="nav">Inside Nav Top Container</div> </div> <div id="main"> <div id="left">Inside Left Main Container</div> <div id="right">Inside Right Main Container</div> </div> <div id="footer">Inside footer Container</div> </div> </body> </html>

      M.Sworna Vidhya

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      I tried your code it is working here fine at my end. Keep the images in image folder. Keep style sheet file in css folder. Both of these folders (image and css) should be at the same level of your folder hierarchy. Now when you are referring image file try to refer it as follows.

      background-image:url("../images/disdat-gold-red.gif");

      HTH

      Jinal Desai - LIVE Experience is mother of sage....

      S 1 Reply Last reply
      0
      • S swornavidhya_m

        I'm trying to create a tableless website. When using external stylesheet, the background-image property alone is not working with my external stylesheet. Other properties are working fine with the external stylesheet. I'm getting fuzzed to continue. My external stylesheet (style.css) and is placed in folder 'css' code is: The image is in folder 'images'. When surfng the google with 'background-image not working in external stylesheet' i found that if we place css in different folder and made a call for an image in differnt folder we've to give mention as

        background-image:url("../images/disdat-gold-red.gif");

        - even this failed. Again when searched, i found that instead of saying 'background-image' give code as follows for which they answered it worked fine. And the code is:

        background: #000000 url(images/disdat-gold-red.gif) repeat-x;

        - even this get failed for me. I'm attaching my html file along with my css file. Coding part in "style.css" #header { text-align:center; font-family:arial, verdana, 'times new roman'; font-size:15pt; font-weight:bold; color:#0ac0af; padding:2% 0 15% 0; background:url(images/disdat-gold-red.gif) no-repeat; } HTML code is: <html> <head> <meta name="GENERATOR" content="Microsoft FrontPage 6.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>Try Web Page</title> <link type=text/css rel=stylesheet href=css/style.css> </head> <body> <div id="container"> <div id="top"> <div id="header">Inside Header Top Container</div> <div id="nav">Inside Nav Top Container</div> </div> <div id="main"> <div id="left">Inside Left Main Container</div> <div id="right">Inside Right Main Container</div> </div> <div id="footer">Inside footer Container</div> </div> </body> </html>

        M.Sworna Vidhya

        T Offline
        T Offline
        T M Gray
        wrote on last edited by
        #3

        Make all of your references relative to the root (start with /). Or use a base tag.

        1 Reply Last reply
        0
        • L Lost User

          I tried your code it is working here fine at my end. Keep the images in image folder. Keep style sheet file in css folder. Both of these folders (image and css) should be at the same level of your folder hierarchy. Now when you are referring image file try to refer it as follows.

          background-image:url("../images/disdat-gold-red.gif");

          HTH

          Jinal Desai - LIVE Experience is mother of sage....

          S Offline
          S Offline
          swornavidhya_m
          wrote on last edited by
          #4

          Thank you, desai. Now it works for me.

          L 1 Reply Last reply
          0
          • S swornavidhya_m

            Thank you, desai. Now it works for me.

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            My Pleasure.

            Jinal Desai - LIVE Experience is mother of sage....

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups