Video width property
The Video object
Example
Modify the width of the video player:
document.getElementById("myVideo").width = "500";
Try it »
Definition and Usage
The width property is used to set or return the width of the video player.
The width property describes the width of the video player, in pixels.
**Tip:** It is a good practice to specify the height and width of the video. If these attributes are set, space will be reserved for the video when the page loads. If they are not set, the browser cannot determine the dimensions of the video in advance, so it cannot reserve appropriate space for it. As a result, the layout may change during page loading.
**Note:** Do not use the height and width attributes to scale the video! Shrinking the video via the height and width attributes only forces the user to download the original video (even though it appears smaller on the page). The correct method is to compress the video with software before using it on the web page.
Browser support

All major browsers support the width property.
Note: Internet Explorer 8 and earlier IE versions do not support
Syntax
Return the width property:
videoObject
.width
Set the width property:
videoObject
.width=
pixels
Attribute values
| Value | Description |
|---|---|
| pixels | Describes the width of the video player, in pixels (e.g.: width="100") |
Technical Details
| Return value: | A number representing the width of the video, in pixels. |
|---|
More examples
Example
Get the width of the video:
var x = document.getElementById("myVideo").width;
x Output value:
320
Try it »
Related pages
HTML Reference Manual: HTML
The Video object