MyInternships.in

HTML5

What are the Media Element Tags Introduced by HTML5?

Before HTML5, playing audio or video on a web page required plugins like Flash. HTML5 introduced native media elements — <audio>, <video>, <source>, and <track> — that let browsers play media directly, with built-in controls, multiple format fallbacks, and captions.


The HTML5 Media Element Tags

TagPurpose
<audio>Embeds sound content such as music or podcasts
<video>Embeds a video with optional controls and poster image
<source>Specifies multiple media files so the browser picks one it supports
<track>Adds text tracks — subtitles, captions, or descriptions

Runnable Video Example

Native video with controls and multiple sources
Example
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>HTML5 Video Demo</title>
</head>
<body>
  <h2>HTML5 Video</h2>
  <video width="400" controls poster="">
    <source src="https://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4">
    <track kind="captions" srclang="en" label="English">
    Your browser does not support the video tag.
  </video>
</body>
</html>

Runnable Audio Example

Native audio with controls and a source fallback
Example
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>HTML5 Audio Demo</title>
</head>
<body>
  <h2>HTML5 Audio</h2>
  <audio controls>
    <source src="https://www.w3schools.com/html/horse.mp3" type="audio/mpeg">
    Your browser does not support the audio element.
  </audio>
</body>
</html>
💡

Provide multiple <source> elements in different formats (MP4, WebM, Ogg). The browser plays the first format it supports and ignores the rest.

Common Media Attributes

  • controls — shows the browser's play/pause/volume UI.
  • autoplay — starts playback automatically (often muted is required).
  • loop — repeats the media when it ends.
  • muted — starts with sound off.
  • poster (video only) — an image shown before playback.
  • preload — hints how much to load in advance (none/metadata/auto).

Key Takeaways

  • HTML5 plays media natively — no Flash required.
  • <audio> and <video> are the container tags.
  • <source> supplies format fallbacks; <track> supplies captions.
  • Always add fallback text between the tags for old browsers.

Related HTML Topics

Keep learning with these closely related tutorials.

Ready to use your HTML skills?

Find web development internships and fresher jobs across India.

Browse Web Dev Internships