set id for element html code example
Example 1: get id of element javascript
var element = document.getElementsByTagName("div")[0];
var id = element.id;
Example 2: html id
<style>
#grepperHeader {
background-color: lightblue;
color: navy;
padding: 40px;
text-align: center;
}
</style>
<h1 id="grepperHeader">grepperHeader</h1>