"."/> ".">

Home  >  Article  >  Web Front-end  >  How to use the source tag of html5

How to use the source tag of html5

WBOY
WBOYOriginal
2022-06-01 17:54:193000browse

In HTML5, the source tag is used to provide different types of video or audio files for the browser to select. The syntax is "".

How to use the source tag of html5

The operating environment of this tutorial: Windows 10 system, HTML5 version, Dell G3 computer.

The source tag of html5

tag defines media resources for media elements (such as

tag allows you to specify two video/audio files for the browser to choose based on its media type or codec support.

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 is required when applied to the tag. Specify image URLs to use in different situations.

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:

How to use the source tag of html5

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn