简体   繁体   中英

video tag of html5

I am familiar with html4 but not in html5. I am starting to learn. But I am sticking in video and audio tags. for video tag I have written like:

<video width="320" height="240" controls="controls" style="border:2px solid #ccc;">
   <source src="Wildlife.mp4" type="video/mp4" />
   <source src="Wildlife.wmv" type="video/wmv" />
   Your browser does not support the video tag.
  </video>

where as code for audio tag is like:

<audio controls="controls">
    <source src="Kalimba.ogg" type="audio/ogg" />
    <source src="Kalimba.MP3" type="audio/mpeg" />
    Your browser does not support the audio element.
   </audio>

the video file "Wildlife.wmv" and audio file "Kalimba.MP3" are on the same folder where the above html file is present. Also I confess that these types of code I got from http://www.w3schools.com/html5/html5_video.asp though I did not understand what is the need for writing source tag twice with different extensions.

Well, it's for fallback, webkit browsers only support a certain type of files, while gecko based browsers (like Firefox) only support a different kind. So it's there to accommodate the difference between the browsers and allow all of them to display the file corretly.

If I may suggest, don't go to w3schools for information. It's a generally bad and misleading site.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM