A sound clip of Zersiax's screen reader in action.
audio
标签用于呈现音频内容,它也具有语义化特性。可以在audio
上下文中为音频内容添加文字说明或者字幕链接,使听觉障碍用户也能获取音频中的信息。
audio
支持controls
属性,可以使浏览器为音频提供具有开始、暂停等功能的播放控件。controls
属性是一个布尔属性,只要这个属性出现在audio
标签中,浏览器就会开启播放控件。
举个例子:
```html
```
注意:p
标签之后添加一个具有controls
属性的audio
标签。然后在audio
标签内添加一个source
标签,并且设置src
属性为"https://s3.amazonaws.com/freecodecamp/screen-reader.mp3",并且设置type
属性为"audio/mpeg".
注意:audio
标签。'
testString: assert($('audio').length === 1);
- text: '确保你的audio
标签是闭合的。'
testString: assert(code.match(/<\/audio>/g).length === 1 && code.match(/audio
标签应具有controls
属性。'
testString: assert($('audio').attr('controls'));
- text: '你的代码应具有source
标签。'
testString: assert($('source').length === 1);
- text: 'source
标签应该在audio
标签中。'
testString: assert($('audio').children('source').length === 1);
- text: 'source
标签中src
属性的值应该与教程中的链接一致。'
testString: assert($('source').attr('src') === 'https://s3.amazonaws.com/freecodecamp/screen-reader.mp3');
- text: 'source
标签中应具有type
属性,其值为 audio/mpeg。'
testString: assert($('source').attr('type') === 'audio/mpeg');
```
A sound clip of Zersiax's screen reader in action.