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.


width = htmlVideoElement.videoWidth;


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.

{{page("/en-US/docs/Web/API/HTMLVideoElement/videoHeight", "About intrinsic width and height", 0, 1)}}


This example creates a handler for the resize event that resizes the <video> element to match the intrinsic size of its contents.

let v = document.getElementById("myVideo");

v.addEventListener("resize", ev => {
  let w = v.videoWidth;
  let h = v.videoHeight;

  if (w && h) { = w; = h;
}, false);

Note that this only applies the change if both the videoWidth and the videoHeight are non-zero. This avoids applying invalid changes when there's no true information available yet for dimensions.


Specification Status Comment
HTML Living Standard
The definition of 'HTMLVideoElement.videoWidth' in that specification.
Living Standard
The definition of 'HTMLVideoElement.videoWidth' in that specification.
Recommendation Initial definition.

Browser compatibility

BCD tables only load in the browser