Atribut src HTML <video>

tag <video> HTML

Contoh

Putar video:

<video src="movie.ogg" controls>
  Your browser does not support the video tag.
</video>

Definisi dan Penggunaan

Atribut srcmenentukan lokasi (URL) file video.

Contoh di atas menggunakan file Ogg, dan akan berfungsi di Chrome, Edge, Firefox, dan Opera.

Untuk memutar video di Internet Explorer dan Safari lama, kita harus menggunakan file MPEG4.

Untuk membuatnya berfungsi di semua browser - tambahkan beberapa <source> elemen di dalam <video>elemen. Setiap <source>elemen dapat menautkan ke file video yang berbeda. Browser akan menggunakan format pertama yang dikenali:

Contoh

<video width="320" height="240" controls>
  <source src="movie.mp4" type="video/mp4">
  <source src="movie.ogg" type="video/ogg">
  Your browser does not support the video tag.
</video>

Dukungan Peramban

Angka-angka dalam tabel menentukan versi browser pertama yang sepenuhnya mendukung atribut tersebut.

Attribute
src 4.0 9.0 3.5 3.1 11.5

Atribut srcini didukung di semua browser utama, namun, format file yang ditentukan mungkin tidak didukung di semua browser.


Sintaksis

<video src="URL">

Nilai Atribut

Value Description
URL The URL of the video file.

Possible values:

  • An absolute URL - points to another web site (like src="http://www.example.com/movie.ogg")
  • A relative URL - points to a file within a web site (like src="movie.ogg")

tag <video> HTML