CSS link to html | SoloLearn: Learn to code for FREE!


CSS link to html

Hi can someone help me with this issue. My Css file is in the same directory as my html file. But my image isn't loading. I'm using sublime text. My css code is div { background: url("IMG_3672.JPG") no-repeat; background-size: cover; } Below is my html file <head> <link rel="stylesheet" href="HelloWorld.css"> </head> <body> <div></div> </body>

3/10/2019 2:26:26 PM

Tan Fu Yu

29 Answers

New Answer



hmmm unless the url is wrong... try width: 100% and height: 100% to test if it isnt just squashed up


Try using other css properties to see if its the image that is not loading or is it that css file is not linked properly with html. If other properties too don't work you have problem wih linking of css file. If it does check this: Is your image in the same directory? Are you using the right file extension?


Is image in same directory?


So, there is 3 file in same folder? .html, .css, .jpg


Try div width\height in px, in % don't work at me too. and take out " from url. simple (.jpg)


In my guides it written whithout ", but yes, it works and with ". When you take size of div with picture size in px, did it work?


Try write path to image in .html, not in css. As <img>.


How i find px instead % for myself at now? Your div empty, try to place in it some word. With % it will appear and picture appear in size of word. When i write in px in size of picture. Picture appear fully.


Mac... Mac.. For mac all usual css selectors works properly? Or, how for webkit, you should write -webkit-...?


div { background: url("IMG_3672.JPG") no-repeat; background-size: cover; Padding:10%; }


When div has no element then the div space is not occupied when we put padding it create a invisible wall covering div so in that space it get display according to me


You have not inserted div in html that y it not showing effects 😂😂 in css Chang div to body it will definitely work


Okay in css just add padding I just tried it it's working


Николай Шаповаленко yes save html and css in the same folder


Николай Шаповаленко yes


「HAPPY TO HELP」 tried width and height 100% too but it still doesn't work


<link rel="stylesheet" type="text/css" href="name_of_file.css"> Try type


Николай Шаповаленко Yash🏁🔘 「HAPPY TO HELP」 its solved now. Thanks for the help!


「HAPPY TO HELP」 it still doesn't work :/