Ravi
Ravi

Reputation: 3

How to pass a value from HTML to CSS

I want to change the theme colour based on theme name that is available in JSP page, How can I pass a variable that contain theme name from JSP to CSS file.

Upvotes: 0

Views: 858

Answers (1)

Yassin Mo
Yassin Mo

Reputation: 600

you can "pass" the value from the inline HTML to the CSS by having something like this:

index.html

<div style="--main-color: red;">RED</div>

style.css

div { background-color: var(--main-color); }

Upvotes: 3

Related Questions