I'm trying to use inline css because I have some parameters I need to pass which I can't do it in css files. Everything is fine if I set the style for one element, for example :
<div class="example" style="background-color:#**<?=$model->color?>**">
But because there are lots of elements need that color parameter, can I put all of them in one style? If in css, I do it like this :
.example h1, h2, li, p a {color: red};
I'm trying this in inline css but it doesn't work :
<div class="example" style="h1, h2, li, p a color:#**<?=$model->theme_color;?>**">
Does anyone know how to do this? And may I do it inline?
This should do it
<?php
echo "<style>
.example h1, h2, li, p a {
color: $model->theme_color
}
</style>";
?>
Another way:
<style>
.example h1, h2, li, p a {
color: <?php echo $model->theme_color; ?>;
}
</style>
What you probably need is internal CSS (instead of inline CSS) - that's where you include your CSS within style tags. So something like
<!-- your external CSS files -->
<style>
h1, h2, li, p a { color:#**<?=$model->theme_color;?>** }
</style>
<body>
<!-- your HTML -->
</body>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With