I'm trying to add an image in my CSS

I’m trying to add an image in my CSS with the theme folder code, <?php bloginfo('template_directory'); ?>, which works in HTML but for some reason it’s not working in the CSS. Does anyone know why or a solution?

Here’s my code:

background: url("<?php bloginfo('template_directory'); ?>/images/bg.jpg");

Solutions Collecting From Web of "I'm trying to add an image in my CSS"