HTML <video> width attribute
Definition and Usage
width
The attribute specifies the width of the video player in pixels.
Tip:Always specify the video's height and width
attributes. If these attributes are set, the space required by the video will be reserved when the page is loaded. However, if these attributes are not set, the browser does not know the size of the video and cannot reserve appropriate space for it. The result is that the page layout will change during loading (when the video is loading).
Note:Please do not use height
and width
Adjust the video size attributes! Using these attributes to shrink large videos will force users to download the original video (even if it looks small on the page). The correct method is to resize the video with a program before using it on a webpage.
Example
A video player with specified height and width has been set:
<video width="640" height="360" controls> <source src="shanghai.mp4" type="video/mp4"> <source src="shanghai.ogg" type="video/ogg"> Your browser does not support the video tag. </video>
Syntax
<video width="pixels">
Attribute Value
Value | Description |
---|---|
pixels | Width of the video in pixels (for example, width="100"). |
Browser Support
The numbers in the table indicate the first browser version to fully support this attribute.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
4.0 | 9.0 | 3.5 | 3.1 | 11.5 |