const stylesheet = new CSSStyleSheet();
stylesheet
.replace("body { font-size: 1.4em; } p { color: red; }")
.then(() => {
console.log(stylesheet.cssRules[0].cssText);
})
.catch((err) => {
console.error("Failed to replace styles:", err);
});CSSStyleSheet: replace() method / notebook
CSSStyleSheet: replace() method
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.