const button = document.getElementById("superCoolButton");
// 1 - setting the property
// properties are in camel.Case
button.style.backgroundColor = "black";
button.style.color = "white";
// 2 - by using keys to set the property
// keys are in the kebab-case
button.style["background-color"] = "black";
button.style["color"] = "white";
// 3 - setting the css Text property will parse it as normal css.
button.style.cssText = "background-color:black; color:white;";
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter