Background image using css isnt working | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Background image using css isnt working

I'm linking my stylesheet using CSS the correct way... and my CSS seems fine but my image isn't showing up on my page. What is it that I could be doing wrong??? HTML <head> <link href="../../Desktop/MyPortalPage/styles.css" rel="stylesheet" type="text/css"> </head> CSS @charset "utf-8"; /***** body CSS *****/ body{ background-image: image("BRIDGE3.jpg"); background-repeat: no-repeat; }

1st Jan 2018, 2:48 AM
Larry Foster
Larry Foster - avatar
8 Answers
+ 5
background-image: url("../images(for exmp)/yourImage.jpg");
1st Jan 2018, 3:06 AM
Botol
Botol - avatar
+ 5
i think in link tag you cant use "../../"
1st Jan 2018, 3:14 AM
Botol
Botol - avatar
+ 5
without first slash in link tag, in url if the image is in the current folder use just url("image"), otherwise use "../image"
1st Jan 2018, 3:37 AM
Botol
Botol - avatar
+ 1
im not sure but i think it should be: body{ background-image: url("BRIDGE3.jpg"); background-repeat: no-repeat; }
1st Jan 2018, 3:07 AM

+ 1
ok I will try that... Happy new year by the way!
1st Jan 2018, 3:46 AM
Larry Foster
Larry Foster - avatar
0
I tried to use url() as well... it still didnt work. What else could be the problem???
1st Jan 2018, 3:09 AM
Larry Foster
Larry Foster - avatar
0
<link href="/Desktop/MyPortalPage/styles.css" rel="stylesheet" type="text/css"> still no differences... I tried it in many different ways, I kinda wanted to just include the CSS in the HTML but I have other pages I want to use this style for.
1st Jan 2018, 3:20 AM
Larry Foster
Larry Foster - avatar
0
got it.... thanx Obsessed and icreiuheciijc for all the help.
3rd Jan 2018, 2:15 AM
Larry Foster
Larry Foster - avatar