Latest web development tutorials

HTML DOM Video width attribute

Video Object Reference Video Object

Examples

Modify the width of the video player:

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

try it"

Definition and Usage

width property sets or returns the width of the video player.

width attribute describes the width of the video player in pixels.

Tip: predetermined width and height of the video is a good habit.If you set these properties, when the page loads will set aside space for the video. If you do not set these properties, the browser can not be pre-determined dimensions of the video, so you can not reserve a suitable space for the video. As a result, in the process of loading the page, its layout will change.

Note: Do not scale the video by height and width attributes!By height and width attributes to narrow the video will only force the user to download the original video (even though it looks small on the page). Before the correct approach is to use the video on the page, using the software for video compression.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support width attribute.

Note: Internet Explorer 8 and earlier versions of IE do not support the <video> element.


grammar

Back width attributes:

videoObject .width

Setting the width property:

videoObject .width = pixels

Property Value

value description
pixels It describes a video player width in pixels (eg: width = "100")

technical details

return value: Number that video width in pixels.


More examples

Examples

Get width of the video:

var x = document.getElementById ( "myVideo") width.;

x output values:

320

try it"


Related Pages

HTML Reference Manual: HTML <Video> width attribute


Video Object Reference Video Object