How to reference a theme image in a stylesheet?

It depends on your image and stylesheet location.

But this is the syntax:

.theme-image {
  background-image: url('../images/header-img.jpg');
}

The above code is for the structure

wp-content
 - themes
  - your-theme 
    - images
     - header-img.jpg
    - css
     - style.css

You are making the browser come one directory before and search for images directory.

Leave a Comment