--- id: html-audio title: "HTML Audio" category: "Frontend" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["audio element", "", "HTML5 audio", "embed audio", "audio controls"] duplicate_of: "" source_trust_level: "B" confidence_score: 0.90 created_at: 2026-06-23 updated_at: 2026-06-23 review_reason: "" merge_history: [] tags: ["html", "web", "frontend", "media", "audio", "html5", "w3schools"] raw_sources: ["https://www.w3schools.com/html/html5_audio.asp"] applied_in: [] github_commit: "" --- # [[HTML Audio]] ## π― ν μ€ ν΅μ°° (One-line insight) The HTML `` element plays sound natively in a page; multiple `` children let the browser pick the first supported format, with `controls`, `autoplay`, and `muted` attributes governing playback. [S1] ## π§ ν΅μ¬ κ°λ (Core concepts) - **`` plays sound** β it embeds an audio player directly in the page. [S1] - **`controls` adds the UI** β the `controls` attribute adds audio controls such as play, pause, and volume. [S1] - **Multiple `` for fallback** β list several `` elements with different formats; the browser uses the first recognized one. Text between the tags shows if none is supported. [S1] - **`autoplay` starts on load**, but Chromium browsers do not allow autoplay in most cases; muted autoplay is always allowed. [S1] - **Three HTML-standard formats** β MP3, WAV, and Ogg. [S1] - **Scriptable** β like video, audio has DOM methods, properties, and events for JavaScript control. [S1] ## π§© μΆμΆλ ν¨ν΄ (Extracted patterns) - **Multi-source fallback pattern** β `` wrapping ordered `` elements + fallback text. [S1] - **Format ordering pattern** β list the preferred format's `` first. [S1] - **Muted autoplay pattern** β `autoplay muted` to start playback within browser autoplay policies. [S1] ## π μΈλΆ λ΄μ© (Details) **The HTML `` element** β used to play an audio file on a web page. To play an audio file, use the `` element. The `controls` attribute adds audio controls (play, pause, volume). The `` elements link to different audio files; the browser uses the first recognized format. The text between `` and `` is displayed only in browsers that do not support the element: [S1] ```html Your browser does not support the audio element. ``` **HTML `` autoplay** β to start an audio file automatically, use the `autoplay` attribute. Note: Chromium browsers do not allow autoplay in most cases; however, muted autoplay is always allowed: [S1] ```html Your browser does not support the audio element. ``` Add `muted` after `autoplay` to let the file start playing automatically (but muted): [S1] ```html Your browser does not support the audio element. ``` **HTML audio formats** β three formats are supported: MP3, WAV, and Ogg. Their MIME (media) types: [S1] | Format | Media Type | |---|---| | MP3 | audio/mpeg | | OGG | audio/ogg | | WAV | audio/wav | Browser support varies by format (per the source): MP3 and WAV are supported across Edge/IE, Chrome, Firefox, Safari, and Opera; OGG is supported in Edge (from Edge 79), Chrome, Firefox, and Opera, but not Safari. [S1] **HTML audio β methods, properties, and events** β HTML defines DOM methods, properties, and events for the `` element, allowing JavaScript to load, play, and pause audio, set duration and volume, and react to events. The source directs to the "HTML Audio/Video DOM Reference" for the full list. [S1] **HTML audio tags** β [S1] | Tag | Description | |---|---| | `` | Defines sound content | | `` | Defines multiple media resources for media elements, such as `` and `` | ## π οΈ μ μ© μ¬λ‘ (Applied in summary) The examples above are the canonical applied uses: a controlled player offering Ogg with an MP3 fallback, an autoplay variant, and a muted-autoplay variant that complies with modern browser autoplay policies. No external project/commit applications found in the source. ## π» μ½λ ν¨ν΄ (Code patterns) Standard audio player with fallback (HTML): ```html Your browser does not support the audio element. ``` Muted autoplay (HTML): ```html ``` ## βοΈ λͺ¨μ λ° μ λ°μ΄νΈ (Contradictions & updates) No contradictions found in the source. As with video, the notable constraint is browser autoplay policy: `autoplay` alone is blocked by Chromium browsers in most cases, so `muted` is required for reliable autoplay. [S1] ## β κ²μ¦ μν λ° μ λ’°λ - **μν:** draft - **κ²μ¦ λ¨κ³:** conceptual (μ€μ μ μ© μ¬λ‘ λ°κ²¬ μ applied/validatedλ‘ μΉκ²© κ°λ₯) - **μΆμ² μ λ’°λ:** B (W3Schools β widely used educational reference, not a primary standards body) - **μ λ’° μ μ:** 0.90 - **μ€λ³΅ κ²μ¬ κ²°κ³Ό:** μ κ· μμ± (New discovery) ## π μ§μ κ·Έλν (Knowledge Graph) - **μμ/루νΈ:** [[HTML Tutorial]] - **κ΄λ ¨ κ°λ :** [[HTML Video]], [[HTML Media]], [[HTML Plug-ins]], [[HTML5]] - **μ°Έμ‘° λ§₯λ½:** Referenced when embedding playable audio with cross-browser format fallbacks. ## π μΆμ² (Sources) - [S1] W3Schools β HTML Audio β https://www.w3schools.com/html/html5_audio.asp ## π λ³κ²½ μ΄λ ₯ (Change history) - 2026-06-23: Initial draft synthesized from the W3Schools "HTML Audio" page (Astra wiki-curation, P-Reinforce v3.1 format).