TheRed TheRed - 7 months ago 34
HTML Question

HTML elements behind audio tag not displayed

I have the following code:


<input id="audio_file" type="file" accept="audio/*" />
<audio id="audio_player" />


However only the div before but not after the audio tag is rendered. How can I fix this?

Answer Source

You need to close your audio correcty with <audio></audio> because it isn't a self closing tag.



<input id="audio_file" type="file" accept="audio/*" />
<audio id="audio_player"></audio>



Inside the audio tag you could insert a source, track or append a text conent.
The text content would be displayed if the browser dosn't support the audio api.

<!-- from mdn webdocs -->
<audio controls="controls">
  Your browser does not support the <code>audio</code> element.
  <source src="foo.wav" type="audio/wav">
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download