<html>
<body>
<p id="p2">Hello World!</p>
<script>
document.getElementById("p2").style.color = "blue";
</script>
</body>
</html>
document.getElementById("myH1").style.color = "red";
var style = document.createElement('style');
style.innerHTML = `
#target {
color: blueviolet;
}
`;
document.head.appendChild(style);
// Create our shared stylesheet:
const sheet = new CSSStyleSheet();
sheet.replaceSync('#target {color: darkseagreen}');
// Apply the stylesheet to a document:
document.adoptedStyleSheets = [sheet];
var element = document.createElement('select');
element.style.maxWidth = "100px";
var style = document.createElement('style');
document.head.appendChild(style);
style.sheet.insertRule('#target {color: darkseagreen}');
document.getElementById('target').style.color = 'tomato';