Adding Audio in HTML
The <audio>
element allows embedding audio files.
<audio controls>
<source src="audio.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
HTMLAudio Attributes
controls
: Displays play, pause, and volume controls.autoplay
: Starts playing automatically.loop
: Repeats audio.muted
: Mutes the audio.
Embedding Video
The <video>
element allows adding videos.
<video width="600" controls>
<source src="video.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
HTMLVideo Attributes
poster
: Sets a preview image before playback.preload
: Determines if the video loads with the page (auto
,metadata
,none
).
Embedding YouTube Videos
You can embed a YouTube video using an <iframe>
.
<iframe width="560" height="315" src="https://www.youtube.com/embed/example" allowfullscreen></iframe>
HTMLUsing SVG for Scalable Graphics
SVG is used for vector graphics.
<svg width="100" height="100">
<circle cx="50" cy="50" r="40" stroke="black" fill="red" />
</svg>
HTMLCanvas for Drawing Graphics
The <canvas>
element allows drawing with JavaScript.
<canvas id="myCanvas" width="200" height="100"></canvas>
<script>
var canvas = document.getElementById("myCanvas");
var ctx = canvas.getContext("2d");
ctx.fillStyle = "blue";
ctx.fillRect(20, 20, 150, 75);
</script>
HTMLHTML multimedia enhances user experience. Next, we’ll discuss SEO & metadata.