HTMLVideoElement.videoWidth

The HTMLVideoElement interface's read-only videoWidth property indicates the intrinsic width of the video, expressed in CSS pixels. In simple terms, this is the width of the media in its natural size.

See About intrinsic width and height for more details.

Syntax

width = htmlVideoElement.videoWidth;

Value

An integer value specifying the intrinsic width of the video in CSS pixels. If the element's readyState is HTMLMediaElement.HAVE_NOTHING, then the value of this property is 0, because neither video nor poster frame size information is yet available.

About intrinsic width and height

A user agent calculates the intrinsic width and height of the element's media by starting with the media's raw pixel width and height, then taking into account factors including:

  • The media's aspect ratio.
  • The media's clean aperture (the sub-rectangle centered within the media that matches the target aspect ratio).
  • The target device's resolution.
  • Any other factors required by the media format.

If the element is currently displaying the poster frame rather than rendered video, the poster frame's intrinsic size is considered to be the size of the <video> element.

If at any time the intrinsic size of the media changes and the element's readyState isn't HAVE_NOTHING, a resize event will be sent to the <video> element. This can happen when the element switches from displaying the poster frame to displaying video content, or when the displayed video track changes.

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
videoWidth
1
12
3.5
9
10.5
3.1
≤37
18
4
11
2
1.0

© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLVideoElement/videoWidth