Hackforge Academy

Category: react

HTML audio and video

Published on 23 Jun 2026

Explanation

HTML provides the <audio> and <video> elements to embed media directly into web pages without requiring external plugins.

Code:

<audio controls>
  <source src="song.mp3" type="audio/mpeg">
</audio>

Explanation

The <audio> element is used to play audio files. The controls attribute displays play, pause, and volume controls.

Code:

<audio controls>
  <source src="music.mp3" type="audio/mpeg">
  Your browser does not support audio.
</audio>

Explanation

The <video> element is used to display video content. The controls attribute allows users to play, pause, and seek through the video.

Code:

<video width="400" controls>
  <source src="video.mp4" type="video/mp4">
</video>

Explanation

Multiple source elements can be provided to support different media formats and improve browser compatibility.

Code:

<video controls>
  <source src="movie.mp4" type="video/mp4">
  <source src="movie.webm" type="video/webm">
</video>

Explanation

Additional attributes such as autoplay, muted, loop, and poster can enhance the user experience when working with audio and video elements.

Code:

<video controls autoplay muted loop 
poster="thumbnail.jpg">
  <source src="demo.mp4" type="video/mp4">
</video>

๐Ÿš€ Learn Spring Boot with real-world projects

๐Ÿ’ก Build REST APIs step by step

๐Ÿง  Improve backend development skills

๐ŸŽฏ Get career-ready practical training

Join Our Free WhatsApp Community

Direct access to niche-specific mentors and peers on WhatsApp.

๐Ÿ

Python Community

Discuss Django, FastAPI, AI integration, and automation scripts with 15k+ developers.

Join Python Community
โš›๏ธ

React Community

Master Next.js, Framer Motion, and State Management. Share your latest UI components.

Join React Community
โ˜•

Java Community

Deep dives into Spring Boot, Microservices architecture, and high-performance backend ops.

Join Java Community