Set style using pure JavaScript
document.getElementsByTagName('div')[0].style.backgroundColor = 'RED';
<div>sample</div>
There are many ways you can set the background color. But getElementsByTagName does not return a single object. It's a collection of objects
document.body.style.backgroundColor = "green"; // JavaScript
document.getElementsByTagName("body")[0].style.backgroundColor = "green"; // Another one
See the demo