This is my CSS. I have used the correct path. When i load the page on safari, i see an orange square (reference image is an orange logo), on chrome i see nothing.
ul {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
text-align: left;
list-style: none;
font-weight: 100;
}
ul li {
margin-bottom: 10px;
position: relative;
}
ul li::before {
content: "";
background: url(images/icons/heartgoldicon.ico);
width: 20px;
height: 20px;
display: inline-block;
margin-right: 10px;
}
PS: It took me research to learn about the ~~~. The inline code and code block things dont work.
Edit: I just tried to use a link instead and it shows. No idea whats wrong with the images in the icons folder but nothing inside that works. I have images inside ‘images’ and that works fine.
2
Answers
Try changing the background url to-
Maybe the missing ‘/’ before the ‘images’ is causing the problem. I tried the code in Brackets with and without the ‘/’ and it worked fine both the times. However, on the server, it doesn’t work without ‘/’.
A few potential issues that may be causing your icon not to show up:
.ico
formatThe
.ico
format may not work on all browsers and you should use a more known format likepng
orjpg
. It is generally used forfavicons
, not for icons. Some browsers may display them while some may not.Your current path to the image is a relative path, so where your
css
file is located will matter to the search.background: url(images/icons/heartgoldicon.ico)
will search that from the current folder that yourcss
file is located. You can use an absolute path by starting with a/
, and then it will always look for the file from the root folder. Example usebackground: url("/images/icons/your-icon.png")
,