Join the AI Workshop and learn to build real-world apps with AI. A hands-on, practical program to level up your skills.
When we talk about background images, @import, and more, we use the url() function to load a resource:
div {
background-image: url(test.png);
}
In this case I used a relative URL, which looks for the file in the folder where the CSS file lives.
I could go one level up
div {
background-image: url(../test.png);
}
or go into a folder
div {
background-image: url(subfolder/test.png);
}
Or you can load a file from the root of the site:
div {
background-image: url(/test.png);
}
Or I could use an absolute URL to load an external resource:
div {
background-image: url(https://mysite.com/test.png);
}