Skip to main content

One post tagged with "web"

View All Tags

· 8 min read
Forrest Allison

There's a shiny new web feature in browser town, and it's called CSSStyleSheets.

What is CSSStyleSheets?

CSSStyleSheets allows you to manipulate page styling without having to load CSS anywhere in the HTML of the page.

With CSSStyleSheets you can do things like:

const sheet = new CSSStyleSheet();
// Apply a rule to the sheet
sheet.replaceSync("a { color: red; }");
// disable the sheet to remove it from the DOM
sheet.disabled = true;

Neat. Support just became widespread, with adoption by Chrome, Safari, Firefox, etc added in the last year (as of early 2023).