How to display an image along with audio in html/html5?

I want to display an image with an audio attachment like an mp3 file. What's the best way to make this work in html5?

1 answer

  • answered 2020-02-13 00:02 Dustin English

    Something as simple as this?

    <img src="some_image.jpg" />
    <audio controls
       src="some_audio.mp3">
       Your browser does not support the <code>audio</code> element.
    </audio>
    
    

    This will display whatever image with an audio track underneath. If you'd like some sort of dynamic interaction with the img+audio you will need to use javascript. I can give an example if that's the case.