---
title: width
framework: webkitjs
role: symbol
role_heading: Instance Property
path: webkitjs/htmlcanvaselement/1632871-width
---

# width

An integer containing the width of the canvas in CSS pixels.

## Declaration

```data
attribute unsigned long width;
```

## Discussion

Discussion Setting the width or height property, even without changing it, clears the canvas to transparent black and resets all context settings to their defaults, including the coordinate system and transformation matrix. If the width attribute is not specified in the <canvas> tag, the default width is 300 pixels.

## See Also

### Setting Canvas Dimensions

- [height](webkitjs/htmlcanvaselement/1634228-height.md)
