Create a style tag with javascript
•
1 min read
If you want to create programmatically a style tag with javascript, here the tip:
const style = document.createElement('style')
style.type = 'text/css'
style.append(myCSS)
document.head.appendChild(style)
where myCSS is your CSS string you want to inject, such as:
const myCSS = `p{
color: blue;
}`