Video width Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Video


The width property sets or gets the width attribute of a video.

The width attribute sets the width of a video player, in pixels.

Set the width property with the following Values

Value Description
pixels Sets the width of the video player, in pixels (i.e. width="100")

Return Value

A Number, representing the width of the video, in pixels

The following code shows how to change the width of the video player:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<video id="myVideo" width="320" height="240" controls>
  <source src="your.mp4" type="video/mp4">
  <source src="your.ogg" type="video/ogg">
  Your browser does not support the video tag.
</video>/*from  w  w w.jav a m*/

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

function myFunction() {
    document.getElementById("myVideo").width = '200';


Related Tutorials