Easy Tutorial
❮ Prop Colgroup Span Prop Area Pathname ❯

Video width Property

Example

Modify the width of the video player:

document.getElementById("myVideo").width = "500";

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 properties are set, space is reserved for the video when the page loads. If these properties are not set, the browser cannot pre-determine the video's size, which means it cannot reserve appropriate space for the video. The result is that the layout of the page may change during the loading process.

Note: Do not scale the video using the height and width properties! Scaling down the video using these properties will only force the user to download the original video (even if it appears smaller on the page). The correct method is to compress the video using software before using it on the web page.


Browser Support

All major browsers support the width property.

Note: The <video> element is not supported in Internet Explorer 8 and earlier versions.


Syntax

Return the width property:

Set the width property:

Property 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 is:

320

Related Pages

HTML Reference: HTML <video> width Attribute

❮ Prop Colgroup Span Prop Area Pathname ❯