Skip to content
Related Articles

Related Articles

Improve Article

HTML | <canvas> width Attribute

  • Last Updated : 16 May, 2019
Geek Week

The HTML <canvas> width Attribute is used to specify the width of the <canvas> in terms of pixels.


<canvas width="pixels"> 

Attribute Values: It contains the value i.e pixels which specify the width of the canvas in terms of pixel. It has a Default value which is 300.

Example: This Example illustrates the use of width attribute in Canvas Element.

<!-- HTML code to illustrate 
width attribute of canvas tag -->
<!DOCTYPE html>
    <title>HTML canvas Width attribute</title>
<body style="text-align:center;">
    <h2>HTML Canvas Width Attribute</h2>
    <canvas id="geeks" 
            style="border:1px solid black">
        var c = document.getElementById("geeks");
        var cx = c.getContext("2d");
        cx.arc(100, 100, 90, 0, 2 * Math.PI);


Supported Browsers:

  • Google Chrome 4.0
  • Firefox 2.0
  • Edge 9.0
  • Opera 9.0
  • Apple Safari 3.1

Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.

My Personal Notes arrow_drop_up
Recommended Articles
Page :