In HTML5, the source tag is used to provide different types of video or audio files for the browser to select. The syntax is "
The operating environment of this tutorial: Windows 10 system, HTML5 version, Dell G3 computer.
Possible attribute values are as follows:
media media_query specifies the type of media resource for the browser to decide whether to download.
src URL specifies the URL of the media file.
type MIME_type specifies the MIME type of the media resource.
sizes Different page layouts set different image sizes.
srcset URL
The example is as follows:
Audio player with two source files. The browser needs to select the source file it supports (if both are supported, select any one):
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>123</title> </head> <body> <audio controls> <source src="horse.ogg" type="audio/ogg"> <source src="horse.mp3" type="audio/mpeg"> 您的浏览器不支持 audio 元素。 </audio> </body> </html>
Output result:
Recommended tutorial : "html video tutorial"
The above is the detailed content of How to use the source tag of html5. For more information, please follow other related articles on the PHP Chinese website!