DevPrep
  • Interview Prep
  • Projects
  • Resources
  • Pricing
  • About Us
Submit Question
DevPrep
  • Pricing
  • About Us
Submit Question
← From Beginner to Expert in Fundamentals of Frontend
  • Semantic HTML
  • Accessibility (a11y)
  • Forms & Validation
  • Document Metadata & The <head>
  • The Document Object Model (DOM)
  • Character Encoding & Entities
  • Data Attributes & Custom Data
  • Template, Slot & Web Components
  • Responsive Images: Picture, Source & srcset
  • Loading Strategies & Resource Hints
  • The Native Dialog Element
  • Audio, Video & Media APIs
  • SVG Integration & Canvas Basics
  • Advanced Input Types & Datalist
  • Details, Summary, Progress & Meter
  • Global Attributes & Iframe Security
  • Microdata, Schema.org & Structured Data
  • Open Graph & Social Meta Tags
  • Security Headers & CSP in HTML
  • Link Relations & Canonical Tags
← From Beginner to Expert in Fundamentals of Frontend

Audio, Video & Media APIs

15 min read
videoaudiotrackcaptionssubtitlesMedia APIposter

HTML Media Elements

The <video> and <audio> elements provide native media playback with a rich JavaScript API for custom controls.

Video Best Practices

  • Always include a poster attribute (preview image before play)
  • Provide multiple formats via <source> for compatibility
  • Add captions via <track> for accessibility
  • Use preload="metadata" to load duration without downloading the whole file

The <track> Element

KindPurpose
subtitlesTranslation for viewers who do not speak the language
captionsFor deaf/hard-of-hearing: includes sound effects, speaker identification
descriptionsFor blind users: describes visual content
chaptersNavigation within the media

Autoplay Policy

Browsers block autoplay with sound. Autoplay works only if the video is muted or the user has previously interacted with the page. This is a user-experience protection, not a bug.

Practice

  • JavaScript
  • DSA
  • Machine Coding
  • System Design

Resources

  • Learning Tracks
  • Articles
  • Roadmaps
  • Compare Concepts
  • Glossary
  • Developer Tools
  • All Questions

Company

  • About
  • Pricing

Legal

  • Privacy Policy
  • Terms of Service
DevPrep

© 2026 DevPrep. All rights reserved.