Get your own website Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<body>
<p>Click the button to create a HEADER element containing a h3 element with some text.</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
  var x = document.createElement("HEADER");
  x.setAttribute("id", "myHeader");
  document.body.appendChild(x);
  var y = document.createElement("H3"); 
  var t = document.createTextNode("This is a h3 element in a header element");
  y.appendChild(t);
  document.getElementById("myHeader").appendChild(y);
}
</script>
</body>
<!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_header_create by HTTrack Website Copier/3.x [XR&CO'2014], Mon, 05 Sep 2022 15:26:18 GMT -->
</html>