controls

HTML controls Attribute (HTML控件属性)

The HTML controls attribute is a boolean attribute and specifies that the audio/video controls must be displayed. It is new in HTML5. (HTML控件属性是一个布尔属性,指定必须显示音频/视频控件。它是HTML5中的新功能。)

You can use the controls attribute on the following elements: <audio> and <video>.

For the <audio> tag, the controls attribute includes:

  • Play (- 开始 -)

  • Pause (-暂停-)

  • Seeking (寻找)

  • Volume (运动量)

For the <video> tag, the controls attribute includes:

  • Play (- 开始 -)

  • Pause (-暂停-)

  • Seeking (寻找)

  • Volume (运动量)

  • Fullscreen toggle (全屏切换)

  • Captions/Subtitles (标注/副标题)

  • Track (赛道)

Syntax

Syntax (语法)

<tag controls></tag>

Example of the HTML controls attribute used on the <audio> element:

<!DOCTYPE html>
<html>
 <head>
   <title>Title of the document</title>
 </head>
 <body>
   <audio controls src="/build/audios/audio.mp3">
     Your browser does not support the audio element.
(你的浏览器不支持音频插件。)
   </audio>
   <p>Click the play button</p>
 </body>
</html>

Example of the HTML controls attribute used on the <video> element:

<!DOCTYPE html>
<html>
 <head>
   <title>Title of the document</title>
   <style>
     video {
       width: 300px;
       height: 220px;
       border: 1px solid #666;
     }
   </style>
 </head>
 <body>
   <video controls>
     <source src="http://techslides.com/demos/sample-videos/small.ogv" type=video/ogg>
     <source src="/build/videos/arcnet.io(7-sec).mp4" type=video/mp4>
   </video>
   <p>Some information about video</p>
 </body>
</html>


请遵守《互联网环境法规》文明发言,欢迎讨论问题
扫码反馈

扫一扫,反馈当前页面

咨询反馈
扫码关注
返回顶部