I have a simple javascript code below to try out my canvas tag :
javascript
window.addEventListener('load', function() {
var myCanvas = document.getElementById("canvas");
var ctx = myCanvas.getContext("2d");
ctx.fillStyle = "black";
ctx.fillRect(0, 0, 100, 100);
})
however I get different result of above javascript code whenever I style my canvas tag like below:
<body>
<canvas id="canvas" width="300" height="300" style="border:1px solid black" ></canvas>
</body>
or
#canvas{
width: 300px;
height: 300px;
border: 2px solid black;
}
why is this happening? or am i missing some concept of the canvas tag?