HTML Media Tags (Audio and Video)

HTML provides specific tags for embedding media, such as audio and video, directly into a webpage. This allows you to share multiedia content without relying on external media players or plugins.

HTML Media Tags Syntax

Explanation of Syntax:

Tutorials dojo strip
  • <audio>: Embeds an audio file in the webpage. The controls attribute adds play, pause, and volume controls.
  • <video>: Embeds a video file. The width and height attributes define its dimensions, while controls adds video controls.
  • <source>: Specifies the source file and format. It should be placed inside the audio or video tags.
HTML



HTML




HTML Media Tags Example Code

Explanation of Code:

  • The document starts with a <!DOCTYPE html> declaration, followed by <html>, <head>, and <body> tags, setting up the page structure.
  • Inside the <body> section:
    • An <h1> tag provides a main heading for the page.
    • An <h2> tag introduces the audio example, followed by the <audio> tag with the controls attribute. The <source> tag inside specifies the audio file location and format, allowing the audio to play on compatible browsers.
    • A second <h2> tag introduces the video example, followed by the <video> tag, which includes width, height, and controls attributes. The <source> tag specifies the video file location and format, enabling video playback on compatible browsers.
HTML




HTML Labs

Tutorials dojo strip