MDN self-hosted library · e01.org

Content-Security-Policy: style-src directive

Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.

html
<link href="https://not-example.com/styles/main.css" rel="stylesheet" />

<style>
  #inline-style {
    background: red;
  }
</style>

<style>
  @import "https://not-example.com/styles/print.css" print;
</style>
html
<div style="display:none">Foo</div>
js
document.querySelector("div").setAttribute("style", "display:none;");
document.querySelector("div").style.cssText = "display:none;";
js
document.querySelector("div").style.display = "none";
html
<style>
  #inline-style {
    background: red;
  }
</style>

<div style="display:none">Foo</div>
html
<style nonce="2726c7f26c">
  #inline-style {
    background: red;
  }
</style>
html
<style>
  #inline-style {
    background: red;
  }
</style>