English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Reference Manual

HTML Tag大全

HTML: <audio> loop attribute

The loop attribute is a boolean attribute. If present, it specifies that the audio will restart and play in a loop each time it ends.

HTML <audio> tag

Online Example

A song that will automatically replay at the end:

<!DOCTYPE html>
<html>
<title>HTML:<audio> loop attribute - 基础教程网 oldtoolbag.com</title>
<body>
<audio controls loop>
  <source src="horse.ogg" type="audio"/ogg">
  <source src="horse.mp3"type="audio"/mpeg">
  Your browser does not support the audio element.
</audio>
</body>
</html>
Test and see ‹/›

Browser Compatibility

IEFirefoxOperaChromeSafari

Internet Explorer 9+, Firefox, Opera, Chrome, and Safari browsers support the loop attribute.

Note: Internet Explorer 8 and earlier IE browsers do not support the <audio> tag.

Definition and Usage

The loop attribute is a boolean attribute.

If this attribute is set, the audio will play in a loop.

HTML 4.01 with HTML5differences

The <audio> tag is an HTML 5 new tags.

Differences between HTML and XHTML

In XHTML, this attribute is not allowed to be abbreviated, the loop attribute must be defined as <audio loop="loop">.

Syntax

<audio loop>

HTML <audio> tag