HTML Canvas textBaseline top

Description

HTML Canvas textBaseline top

View in separate window

<!DOCTYPE html>
<html>
<body>

<canvas id="canvas" width="640" height="280" style="border:1px solid #d3d3d3;">
Your browser does not support the HTML5 canvas tag.</canvas>

<script>
      let theCanvas = document.getElementById('canvas');
      let context = theCanvas.getContext('2d');

    context.fillStyle = '#aaaaaa';
      context.fillRect(0, 0, 200, 200);/*from w w w . j a  v  a2s.  c om*/
    context.fillStyle    = '#000000';
    context.font         = '20px _sans';
    context.textBaseline = 'top';
    context.fillText  ("Canvas!", 0, 0);

</script>

</body>
</html>



PreviousNext

Related