Home > front end >  is it compulsory to write Html audio type?
is it compulsory to write Html audio type?

Time:02-14

Is it necessary to write audio type in html like .

I have tested it without writing audio type and it is working fine then why should we have to write it?

CodePudding user response:

<audio controls>
  <source src="horse.ogg" type="audio/ogg">
  <source src="horse.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>

ig unless an until it has it's default type... you could ignore the type attribute.

CodePudding user response:

The HTML element is used to embed sound content in documents. It may contain one or more audio sources, represented using the src attribute or the element: the browser will choose the most suitable one. It can also be the destination for streamed media, using a MediaStream.

<figure>
    <figcaption>Listen to the T-Rex:</figcaption>
    <audio
        controls
        src="/media/cc0-audio/t-rex-roar.mp3">
            Your browser does not support the
            <code>audio</code> element.
    </audio>
</figure>
  • Related