javascript style

JavaScript
// Getting the element first
var myElement = document.querySelector("#myElement");

// examples for updating styles
myElement.style.color = "blue";
myElement.style.backgroundColor = "red";var elem = document.querySelector('#some-element');

// Set color to purple
elem.style.color = 'purple';

// Set the background color to a light gray
elem.style.backgroundColor = '#e5e5e5';

// Set the height to 150px
elem.style.height = '150px';
const title = document.querySelector('h1')

//title.setAttribute('style', 'margin: 50px');

console.log(title.style); // Show all style propertyes
console.log(title.style.color); // Log a color in console

title.style.margin = '50px'; // Set a margin of title
title.style.color='crimson'; // Set a color of title
title.style.fontSize = '60px'; // Set font size of title// background-color
<element>.style.backgroundColor = '#000';
// background
<element>.style.background = '#000';
// color
<element>.style.color = '#fff';
// box-sizing
<element>.style.boxSizing = 'border-box';
// font-family
<element>.style.fontFamily = '\'Times New Roman\', Times, serif';
// font-size
<element>.style.fontSize = '16px';
// margin
<element>.style.margin = 0;
// padding
<element>.style.padding = '20px';
// width
<element>.style.width = '100%';
// height
<element>.style.height = '100%';
// margin-left
<element>.style.marginLeft = 0;
// font-weight
<element>.style.fontWeight = 400; document.getElementById("myH1").style.color = "red";  element.style.backgroundColor = "red";   // set the background color of an element to red
Source

Also in JavaScript: