Create a Header Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Header


You can create a <header> element by using the document.createElement() method:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<button onclick="myFunction()">create a HEADER element containing a h3 element with some text</button>

function myFunction() {/*from   w  w  w . j av a  2 s  .  c o m*/
    var x = document.createElement("HEADER");
    x.setAttribute("id", "myHeader");

    var y = document.createElement("H3");
    var t = document.createTextNode("This is a h3 element in a header element");



Related Tutorials