user image

Mohamed Aboelfotoh
Published in : 2022-02-13

Can't move the background-image code from CSS file to HTML file.

HTML & CSS

Basically, I'd want to change the background image code from the.css file to the.html page. The image does not appear on my website when I do this.

The picture (photo.png) is successfully shown and I use the following code.

<div >
.select-resource {
  margin-bottom:5px;
  background-position: 400px -5px;
}

But, I need to use the next code, but still the picture does not appear when I do so. The code is as follows:

<div >
.select-resource {
  margin-bottom:5px;
background-position: 400px -5px;
}

Is there anyone who can guide me with this? 

Comments

Joseph Morgan Date : 2022-02-13

Best answers

11

Best answers

11

This must be because the URL is missing, when you use url() in CSS file it uses the location from the CSS file & when you move it to HTML it should be different because both HTML & CSS are not in the same Folder

Mahmoud Santos Date : 2022-02-21

Best answers

2

Best answers

2

try to add single quotes like :

background-image: url('path');

 

<div >

 

hope it worked

Leave a comment

Join us

Join our community and get the chance to solve your code issues & share your opinion with us

Sign up Now

Related posts

How can I add engraved style to my buttons using CSS?
Publish date: 2022-03-01 | Comments: 5

Tag: HTML & CSS

Is OOCSS still a good CSS architecture in 2022?
Publish date: 2022-02-08 | Comments: 2

Tag: HTML & CSS

How to align an Textarea in the middle of the webpage
Publish date: 2022-02-27 | Comments: 1

Tag: HTML & CSS

Do I have to upload the sass files or just the CSS file?
Publish date: 2022-02-11 | Comments: 1

Tag: HTML & CSS

What is the need for using (for) attr in the label of an input tag?
Publish date: 2022-02-11 | Comments: 2

Tag: HTML & CSS

Searching for a better way to use abstracts in Dart SASS
Publish date: 2022-02-10 | Comments: 0

Tag: HTML & CSS

How to separate the background into three divs that can be flipped?
Publish date: 2022-02-12 | Comments: 1

Tag: HTML & CSS

min-height is not working on td or th
Publish date: 2021-10-20 | Comments: 1

Tag: HTML & CSS