Get your own website Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<style>
.myStyle {
  background-color: coral;
  padding: 16px;
}
.class1 {
  text-align: center;
}
.class2 {
  font-size: 25px;
}
</style>
<body>
<h1>The Element Object</h1>
<h2>The className Property</h2>
<button onclick="myFunction()">Add</button>
<p>Click "Add" to add additional classes to "myDIV".</p>
<div id="myDIV" class="myStyle">
<p>I am myDIV.</p>
</div>
<script>
function myFunction() {
  document.getElementById("myDIV").className += " class1 class2";
}
</script>
</body>
</html>