Get your own website Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<body>
<h1>The Element Object</h1>
<h2>The outerHTML Property</h2>
<p>Click "Change" to change the first h2 header to a h3.</p>
<button onclick="myFunction()">Change</button>
<script>
function myFunction() {
  const element = document.getElementsByTagName("h2")[0];
  element.outerHTML = "<h3>You changed me and my content!</h3>";
}
</script>
</body>
</html>