Using a PHP variable in CSS

I need to read in a HEX color value and use it in a CSS statement. I use this and it sets the color fine.

			?>
			<style> 
				
:root {
  --clr: #1e90ff;
        }


			#id_sc_field_messageinternal {
			  background-color:  var(--clr);
			  font-style: italic;
			}

			#id_StyleViewNew_form4::after 
			{content: "<?php echo "" ?>";
			}	

			</style>
			<?php

The problem is I am reading in the HEX color value from a table , as a variable: {clr} . How do I include that variable in the CSS statement var()

Solved it:
$clr= “#1e9900”;

		?>
		<style> 

		#id_sc_field_messageinternal {
		  background-color:<?php echo $clr ?>;} 
		}
			
		</style>
		<?php
1 Like