Horje

How to add An audio file that will automatically start playing

The audio autoplay attribute. Click on the play button to play a sound.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The audio autoplay attribute</h1>

<p>Click on the play button to play a sound:</p>

<audio controls autoplay>
  <source src="https://samplelib.com/lib/preview/mp3/sample-3s.mp3" type="audio/ogg">
  <source src="https://samplelib.com/lib/preview/mp3/sample-3s.mp3" type="audio/mpeg">
  Your browser does not support the audio element.
</audio>

</body>
</html>

Output should be:

How to add An audio file that will automatically start playing




Type:
html
Category:
Web Tutorial
Sub Category:
HTML Attribute
Uploaded by:
Admin