Latest web development tutorials

HTML video width attribute

HTML video tag Reference Manual HTML <video> tag

Examples

With the specified height and width of the video:

<video width="320" height="240" controls>
<source src="movie.mp4" type="video/mp4">
<source src="movie.ogg" type="video/ogg">
您的浏览器不支持 video 标签。
</video>

try it"

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support width attribute.

Note: Internet Explorer 8 and earlier versions of IE do not support the <video> tag.


Definition and Usage

width attribute specifies the width of the video player.

Tip: predetermined width and height of the video is a good habit. If you set these properties, when the page loads will set aside space for the video. If you do not set these properties, the browser can not be pre-determined dimensions of the video, so you can not reserve a suitable space for the video. As a result, in the process of loading the page, its layout will change.

Note: Do not scale the video by height and width attributes!By height and width attributes to narrow the video will only force the user to download the original video (even though it looks small on the page). Before the correct approach is to use the video on the page, using the software for video compression.


Differences between HTML 4.01 and HTML5

<Video> tag is the new HTML5 tags.


grammar

<video width="pixels">

Property Value

描述
pixels 以像素计的宽度值(比如 "100px" 或 100)。


HTML video tag Reference Manual HTML <video> tag