<!DOCTYPE html>
<html lang="en-US">
<head>
<style>
div{
display: inline-block;
text-align: center;
width: 30px;
}
</style>
</head>
<body>
<script>
var i, j, k;
var m = 1;
for(i=1; i<=9; i+=2)
{
for(j=i; j<9; j++)
document.write(" ");
for(k=1; k<=i; k++)
{
document.write("<div>" +m*m +"</div>");
m++;
}
document.write("<br>");
}
</script>
<p><strong>Note</strong>: In this example, the structure of the pattern is more important. So little <a href="/css" target="_blank">CSS</a> is added.</p>
</body>
</html>