HTML <video> 标籤
Definition and usage
<video>
Tag is used to embed video content in a document, such as movie clips or other video streams.
<video>
Tag contains one or more sources with different video sources <source> tag. The browser will choose the first source it supports.
<video>
and </video>
The text between the tags will only be displayed in browsers that do not support <video>
displayed in the browser of the element.
HTML supports three video formats: MP4, WebM, and OGG.
Browser | MP4 | WebM | Ogg |
---|---|---|---|
Edge | Supported | Supported | Supported |
Chrome | Supported | Supported | Supported |
Firefox | Supported | Supported | Supported |
Safari | Supported | Supported | Not supported |
Opera | Supported | Supported | Supported |
See also:
HTML DOM Reference Manual:คู่มือตาราง DOM แออัลบิวไดโอมาติก HTML
Example
Play video:
<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>
Tips and comments
Tip:For audio files, see the <audio> tag.
Optional attribute
Attribute | Value | Description |
---|---|---|
autoplay | autoplay | Specify that the video should start playing immediately after it is ready. |
controls | controls | Specify the video controls to be displayed (such as play/pause buttons, etc.). |
height | pixels | Set the height of the video player. |
loop | loop | Specify that the video will restart at the end each time. |
muted | muted | Specify that the audio output of the video should be muted. |
poster | URL | Specify the image to be displayed during the download of the video or before the user clicks the play button. |
preload |
|
Specify whether the video should load or how it should load when the page is loaded. |
src | URL | Specify the URL of the video file. |
width | pixels | Set the width of the video player. |
คุณสมบัติโลก
<video>
แท็กยังสนับสนุน คุณสมบัติโลกใน HTML.
คุณสมบัติเหตุการณ์
<video>
แท็กยังสนับสนุน คุณสมบัติเหตุการณ์ใน HTML.
การตั้งค่า CSS โดยเริ่มต้น
ไม่มี
การสนับสนุนโปรแกรมน่าพิมพ์
ตัวเลขในตารางระบุสัปดาห์ที่เซิร์ฟเวอร์สนับสนุนคุณสมบัตินี้ครบถ้วน
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
4.0 | 9.0 | 3.5 | 3.1 | 11.5 |