Styling via style attribute in JavaScript

Let's remember how to style elements using the style attribute. Let's say we have the following element:

<div id="elem"> text </div>

Let's get a reference to it into a variable:

let elem = document.querySelector('#elem');

We change the styles for it:

elem.style.color = 'red';

We read its styles:

console.log(elem.style.color); // shows 'red';
enru