How to set background-image on css

please what is the syntax to set bacckground image of an image in your vscode folder?

Depends on the path to the image and CSS file, but you would use the same path as you would with an img element, that is unless the CSS file is inside its own folder then you would go up one level first ../images/someImage.jpg.

Examples
/root
  /img/background.jpg
index.html
styles.css
body {
  background-image: url('./img/background.jpg');
}

CSS in its own folder:

/root
  /img/background.jpg
index.html
  /styles/styles.css
body {
  background-image: url('../img/background.jpg');
}

thank you. it worked

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.