xxxxxxxxxx
// Changing CSS of ONLY one element
element.style.color = "red"
// Adding a stylesheet
const style = document.createElement("style");
style.setContent = "* {color: red;}";
document.head.appendChild(style)
// OR (less supported)
const sheet = new CSSStyleSheet();
sheet.replaceSync("* {color: red;}");
document.adoptedStyleSheets = [sheet];
xxxxxxxxxx
// my element
const element = document.getElementById("slider")
// several elements with javascript
element.style.cssText = "background-color: red ; width:100%; height:700px;"
// one only ( add css attribute without "-" but in camelCase,
//for exemple background-color = backgroundColor)
element.style.backgroundImage = "url('./my-image.png')"
xxxxxxxxxx
//Create a new stylesheet
const sheet = new CSSStyleSheet();
//Add some CSS to the stylesheet
sheet.replaceSync('#title {color: red}');
// Apply the stylesheet to a document:
document.adoptedStyleSheets = [sheet];