Dofactory.com
Dofactory.com
Earn income with your HTML skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

HTML <video> width Attribute

The width attribute on a <video> tag sets the width of the video player.

The width is specified in pixels -- without the ‘px‘ unit.

Example

#

A width attribute on a <video> element.
The width attribute overrides the original video width.

<video width="320" height="240" controls>
  <source src="/media/movie.mp4" type="video/mp4">
  <source src="/media/movie.ogg" type="video/ogg">
</video>

Using width

The width attribute sets the width of the video element.

The width is defined in pixels, without the 'px' unit.

The browser will maintain the correct aspect ratio if the height is not set.

To define the width in % or other unit, use the CSS width property.

Tip: Try using the actual dimensions of the video file.
It requires fewer resources to play a video in the actual size.


Syntax

<video width="pixels">

Values

#

Value Description
pixels A number. Width of the video in pixels (e.g. 400).

Browser support

Here is when width support started for each browser:

Chrome
4.0 Jan 2010
Firefox
3.5 Jun 2009
IE/Edge
9.0 Mar 2011
Opera
11.5 Aug 2011
Safari
3.1 Mar 2008

You may also like

 Back to <video>

Last updated on Sep 30, 2023

Earn income with your HTML skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

Guides