Latest web development tutorials

HTML video src attribute

HTML video tag Reference Manual HTML <video> tag

Examples

Play a video:

<video src="movie.ogg" controls>
您的浏览器不支持 video 标签。
</video>

try it"

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the src attribute. However, the definition of the file format is not supported by all browsers.

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


Definition and Usage

src attribute specifies the video file on the local path (URL).

Ogg files using the above example, the use of the normal display in Firefox, Opera and Chrome.

If you need to play the video in Internet Explorer and Safari, you must use the MPEG4 file.

If you want to play a video file in all browsers - in <video> element always use the <source> element. <Source> elements can link to different video files. The browser will use the first recognized format:

Examples

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

try it"


Differences between HTML 4.01 and HTML5

<Video> tag is the new HTML5 tags.


grammar

<video src="URL">

Property Value

描述
URL

视频文件的 URL。

可能的值:

  • 绝对 URL - 指向另一个站点(比如 href="http://www.example.com/song.ogg")
  • 相对 URL - 指向网站内的文件(比如 href="song.ogg")


HTML video tag Reference Manual HTML <video> tag