<html>
<head>
<style>
table, th {
border: 1px solid black;
}
</style>
</head>
<body>
<table id="myTable">
<tr id="myTr">
</tr>
</table>
<p>Click the button to create a TH element.</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
var x = document.createElement("TH");
var t = document.createTextNode("table header cell");
x.appendChild(t);
document.getElementById("myTr").appendChild(x);
}
</script>
</body>
</html>