Title: Background Image in Header in CSS
Last modified: March 29, 2021

---

# Background Image in Header in CSS

 *  Resolved [ulim](https://wordpress.org/support/users/ulim/)
 * (@ulim)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/background-image-in-header-in-css/)
 * I’ve noticed that if I create a background image in a header, then it is not 
   created as an HTML element. The URL is only present in the CSS like so:
 *     ```
       [data-header*="type-1"] .ct-header [data-row="top"]
       --background-image: url(http://localhost/wordpress/wp-content/uploads/2020/05/mybackground.jpg);
       ```
   
 * This leads to problems when changing the site’s URL or, as in this case, migrating
   from localhost to the production server. The usual migration tools do not pick
   up on URLs in stylesheets, they only search the database.
 * So I wonder if it would make sense for you to store those values in the database
   instead of in the stylesheet?

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Theme Author [Creative Themes](https://wordpress.org/support/users/creativethemeshq/)
 * (@creativethemeshq)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/background-image-in-header-in-css/#post-14251419)
 * [@ulim](https://wordpress.org/support/users/ulim/) Those values are stored in
   the database (in [theme mods](https://developer.wordpress.org/reference/functions/get_theme_mod/)
   in most cases, to be specific) in the first place. It’s just that we generated
   a `global.css` file upon customizer save based on those DB values. So, if you’d
   run your usual search/replace tool against the DB then just save the customizer
   once — the stylesheet will be in sync again with the right URLs (or just run `
   do_action("customize_save_after")` which will be picked up by the [dynamic CSS](https://creativethemes.com/blocksy/docs/general-options/performance/)
   generator.
 * —
 * Important aside: The above is only relevant if you use the [File](https://creativethemes.com/blocksy/docs/general-options/performance/)
   strategy for CSS output, which is only present when you also use the [Blocksy Companion](https://wordpress.org/plugins/blocksy-companion/)
   plugin. If you don’t use the Companion, just run the search/replace against the
   DB then do a page refresh — you’ll see the right URLs right away.
 * Hope this helps. Please let us know if you still don’t manage to get updated 
   URLs somewhere and we’ll be in touch.
 *  Thread Starter [ulim](https://wordpress.org/support/users/ulim/)
 * (@ulim)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/background-image-in-header-in-css/#post-14261661)
 * Yes, I use the File strategy. Thank you very much for the explanation how things
   work. This is completely fine for me, if just saving the Customizer will regenerate
   the global.css file.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Background Image in Header in CSS’ is closed to new replies.

 * ![](https://i0.wp.com/themes.svn.wordpress.org/blocksy/2.1.41/screenshot.jpg)
 * Blocksy
 * [Support Threads](https://wordpress.org/support/theme/blocksy/)
 * [Active Topics](https://wordpress.org/support/theme/blocksy/active/)
 * [Unresolved Topics](https://wordpress.org/support/theme/blocksy/unresolved/)
 * [Reviews](https://wordpress.org/support/theme/blocksy/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [ulim](https://wordpress.org/support/users/ulim/)
 * Last activity: [5 years, 1 month ago](https://wordpress.org/support/topic/background-image-in-header-in-css/#post-14261661)
 * Status: resolved