<main></main>
main:after {
background: var(--background-color);
content: var(--text);
}
function addStyle(styleString) {
const style = document.createElement("style");
style.textContent = styleString;
document.head.append(style);
}
const text = "Hello from JS!!";
const background = '#ffccff'
addStyle(`
:root {
--text: "${text}";
--background-color: ${background}
}
`);
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.