1

The below code is all inline CSS.

DOESN'T WORK

#Image { background-image: url('Images/home.png'); } 

DOESN'T WORK

#Image { background-image: url('http://localhost:63832/Images/home.png'); } 

But when I copy and paste the url, i can access the image. I can also see this defined and active when I check the css in the browser.

WORKS

<img id="Image" src="Images/home.png" /> 
4
  • Maybe you're using a background property for #Image somewhere else in your code. Are you sure there are no other conflicting styles present. Inspect the #Image in your browser and see what all styles are actually applied to it. Commented Jul 11, 2014 at 6:20
  • did you tried "background:url("image path") no-repeat: left top;" like this with background position ? Commented Jul 11, 2014 at 6:20
  • use background-image: url('Images/home.png') !important Commented Jul 11, 2014 at 6:21
  • background-image, while setting the background of the element, doesn't give the element any size. If you're not getting a file_not_found error in the JS console, then the image is being loaded, but is just not visible. Commented Jul 11, 2014 at 6:30

4 Answers 4

3

Try with width and height properties

#Image { background-image: url('Images/home.png'); width: 100px; height: 100px; } 
Sign up to request clarification or add additional context in comments.

Comments

3

I resolved the same issue by putting ../../ before the path of the image

#Image { background-image: url('../../Images/home.png'); } 

1 Comment

This may or may not work for the OP, depending on their project setup.
1

You must be using a background property for #Image somewhere else in your code. Are you sure there are no other conflicting styles present? Inspect the #Image in your browser and see what all styles are actually applied to it.

Try using !important if you're not sure. But I would avoid using it:

#Image { background-image: url('Images/home.png') !important; } 

Comments

1

Make the css like

 #Image { background-image: url('Images/home.png') !important; } 

if it already defined anywhere in your site is replace and add this.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.