Practical Exercise 13: Integrating Audio into HTML
Discover how to insert sound files into your web pages using the <audio> tag. This practical exercise teaches you how to play audio in HTML with custom controls and modern compatibility.
Activity
Insert an audio file using the <audio> tag. Inside a folder, you should have your HTML file and your audio file, which can be in a subfolder. Use the MP3 format preferably, as it is smaller and offers good quality.
Interactive Solution
Solution with complete HTML code
HTML
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8" />
<title>Audio Integrado</title>
</head>
<body>
<h1>Audio</h1>
<audio controls>
<source src="audio/mi_audio.mp3" type="audio/mpeg" />
Tu navegador no soporta la reproducción de audio.
</audio>
</body>
</html>