<div id="a">
  Hello, world!
</div>
#a {
  background-color: #ccffff !important;
  color: blue;
}
const div = document.createElement("div");
document.getElementById("a")
  .attachShadow({ mode: "open" })
  .appendChild(div);

div.innerHTML = `
  <style>
    :host {
      background-color: #ffffcc !important;
      color: red;
    }
  </style>
  <slot></slot>
`;

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.