-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path08-Audio Tag.html
More file actions
70 lines (62 loc) · 2.18 KB
/
08-Audio Tag.html
File metadata and controls
70 lines (62 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML Audio Tag Examples</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
}
</style>
</head>
<body>
<h1>HTML Audio Tag Examples</h1>
<p>
The <code><audio></code> tag in HTML is used to embed audio content on a web page. It supports various attributes
to control the playback and appearance of the audio player. Here are examples for each attribute:
</p>
<h2>Example 1: Basic Audio with Controls</h2>
<p>
The <code>controls</code> attribute adds playback controls to the audio player, allowing users to play, pause, adjust the volume, and more.
</p>
<audio controls>
<source src="audio/example.mp3" type="audio/mp3">
Your browser does not support the audio element.
</audio>
<h2>Example 2: Autoplay</h2>
<p>
The <code>autoplay</code> attribute automatically starts playing the audio when the page loads. Please note that this can be intrusive, so use it carefully.
</p>
<audio controls autoplay>
<source src="audio/example.mp3" type="audio/mp3">
Your browser does not support the audio element.
</audio>
<h2>Example 3: Loop</h2>
<p>
The <code>loop</code> attribute causes the audio to continuously loop, restarting when it reaches the end.
</p>
<audio controls loop>
<source src="audio/example.mp3" type="audio/mp3">
Your browser does not support the audio element.
</audio>
<h2>Example 4: Muted</h2>
<p>
The <code>muted</code> attribute starts the audio playback with the sound muted.
</p>
<audio controls muted>
<source src="audio/example.mp3" type="audio/mp3">
Your browser does not support the audio element.
</audio>
<h2>Example 5: Multiple Sources with Different Formats</h2>
<p>
Provide multiple <code><source></code> elements to ensure compatibility with different browsers and audio formats.
</p>
<audio controls>
<source src="audio/example.mp3" type="audio/mp3">
<source src="audio/example.ogg" type="audio/ogg">
Your browser does not support the audio element.
</audio>
</body>
</html>