HTML DOM Video width Property
-- Learning is not just about technology, but also about dreams!
- Home
- HTML
- JavaScript
- CSS
- Vue
- React
- Python3
- Java
- C
- C++
- C#
- AI
- Go
- SQL
- Linux
- VS Code
- Bootstrap
- Git
- Local Bookmarks
JavaScript Reference
JavaScript Objects
- JavaScript Array Object
- JavaScript Boolean Object
- JavaScript Date Object
- JavaScript Math Object
- JavaScript Number Object
- JavaScript String Object
- JavaScript RegExp Object
- JavaScript Global Properties/Functions
- JavaScript Operators
- JavaScript Error
Browser Objects
DOM Objects
- HTML DOM Document Object
- HTML DOM Element Object
- HTML DOM Attribute Object
- HTML DOM Event Object
- HTML DOM Console Object
- CSSStyleDeclaration Object
- DOM HTMLCollection
HTML Objects
- <a>
- <area>
- <audio>
- <base>
- <blockquote>
- <body>
- <button>
- <canvas>
- <col>
- <colgroup>
- <datalist>
- <del>
- <details>
- <dialog>
- <embed>
- <fieldset>
- <form>
- <iframe>
- <frameset >
- <img>
- <ins>
- <input> - button
- <input> - checkbox
- <input> - color
- <input> - date
- <input> - datetime
- <input> - datetime-local
- <input> - email
- <input> - file
- <input> - hidden
- <input> - image
- <input> - month
- <input> - number
- <input> - range
- <input> - password
- <input> - radio
- <input> - reset
- <input> - search
- <input> - submit
- <input> - text
- <input> - time
- <input> - url
- <input> - week
- <keygen>
- <link>
- <label>
- <legend>
- <li>
- <map>
- <menu>
- <menuItem>
- <meta>
- <meter>
- <object>
- <ol>
- <optgroup>
- <option>
- <param>
- <progress>
- <q>
- <script>
- <select>
- <source>
- <style>
- <table>
- <td>
- <th>
- <tr>
- <textarea>
- <title>
- <time>
- <track>
- <video>
HTML DOM Video videoTracks Property
Video width Property
Example
Change the width of the video player:
document.getElementById("myVideo").width = "500";
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: It is a good practice to specify the height and width of the video. 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 size of the video, and therefore cannot reserve the appropriate space for it. As a result, the layout of the page will change during loading.
Note: Do not scale the video using the height and width attributes! Scaling the video down using the height and width attributes only forces the user to download the original video (even if it appears smaller on the page). The correct way is to compress the video using software before using it on the webpage.
Browser Support
All major browsers support the width property.
Note: Internet Explorer 8 and earlier IE versions do not support the <video> element.
Syntax
Get the width property:
videoObject.width
Set the width property:
videoObject.width=pixels
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
Example
Get the width of the video:
var x = document.getElementById("myVideo").width;
The value of x will be:
320
Related Pages
HTML Reference: HTML <video> width Attribute
YouTip