Video widthProperty
Video Object
Examples
Modify the width of the video player:
Try it Yourself »
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:Specifying the height and width of a video is a good practice. If these attributes are set, space will be reserved for the video when the page loads. If these attributes are not set, the browser cannot determine the video's dimensions in advance, and thus cannot reserve appropriate space for the video. As a result, the layout will change during page loading.
Note:Do not use the height and width attributes to scale videos! Reducing a video with the height and width attributes will only force users to download the original video (even if it appears smaller on the page). The correct approach is to compress the video with software before using it on a web page.
Browser Support
![]()
All major browsers support the width property.
Note:Internet Explorer 8 and earlier IE versions do not support the <video> element.
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
Examples
Get the width of the video:
xThe output value is:
Try it Yourself »
Related Pages
HTML Reference Manual:HTML <video> width Property
Video Object Other Extensions