rectangle in html canvas code example
Example 1: draw rectangle on canvas javascript
ctx.fillStyle = "(enter color)";
ctx.fillRect(x, y, width, height);
var canvas = document.getElementById("(enter canvas's id)");
var ctx = canvas.getContext("2d");
Example 2: how to make a rectangle in javascript
<html>
<head>
<meta charset="UTF-8">
<title>Pong</title>
<script language="Javascript" type="text/Javascript" src="libraries/p5.js"></script>
<script language="Javascript" type="text/Javascript" src="pong.js" defer></script>
<style> body {padding: 0; margin: 0;} </style>
</head>
<body>
<canvas id="pong" width="600" height="400"></canvas>
</body>
</html>