xxxxxxxxxx
<!DOCTYPE html>
<html>
<head>
<title>Assign HTML code to JavaScript Variable</title>
</head>
<body>
<div id="myId"></div>
<script>
var code = '<h1>Hello World!</h1>' +
'<h3>Welcome to Studytonight</h3>' +
'<p>We at Studytonight believe that by widening the reach of education, by making it freely available, so much can be achieved.</p>';
document.getElementById("myId").innerHTML = code;
</script>
</body>
</html>