New in HTML5.

<audio volume=””> HTML Attribute

0 Shares
Attribute of
<audio> HTML Tag
What does <audio volume=""> HTML Attribute do?
Specifies the initial volume setting of the audio element, in a range from 0.0 to 1.0.

Code Example

<h3>Low Volume </h3>
<audio controls volume="0.1" id="audio-example-low" class="audio-example">
  <!-- One or more source files, each referencing the same audio but in a different file format.
    The browser will choose the first file which it is able to play. -->
   <source src="/wp-content/uploads/flamingos.ogg">
   <source src="/wp-content/uploads/flamingos.mp3">

    You will see this text if native audio playback is not supported.
    <!-- You could use this fall-back feature to insert a JavaScript-based audio player. -->
</audio>

<small>Audio by  <a href="https://soundcloud.com/beeldengeluid">Beeld en Geluid</a> [<a href="http://creativecommons.org/licenses/by-sa/3.0">CC BY-SA 3.0</a>], <a href="https://commons.wikimedia.org/wiki/File%3AArtis%2C_enkele_flamingo's_-_SoundCloud_-_Beeld_en_Geluid.ogg">via Wikimedia Commons</a></small>

<h3>High Volume </h3>
<audio controls volume="0.9" id="audio-example-loud" class="audio-example" src="/wp-content/uploads/flamenco.mp3">

    You will see this text if native audio playback is not supported.
    <!-- You could use this fall-back feature to insert a JavaScript-based audio player. -->
</audio>

<small>Audio by JCZA [<a href="http://creativecommons.org/licenses/by-sa/3.0">CC BY-SA 3.0</a>] , via <a href="https://commons.wikimedia.org/wiki/File:JCZA_-_JCzarnecki-Flamenco.ogg">Wikimedia Commons</a></small>



<style>
.audio-example {
display: block;
}
</style>

Low Volume

Audio by Beeld en Geluid [CC BY-SA 3.0], via Wikimedia Commons

High Volume

Audio by JCZA [CC BY-SA 3.0] , via Wikimedia Commons

Values of the volume Attribute

Value NameNotes
0.0–1.0Sets the volume of the audio playback, in a range between 0.0 (muted) and 1.0 (full).

All Attributes of audio Element

Attribute nameValuesNotes
volume0.0–1.0Specifies the initial volume setting of the audio element, in a range from 0.0 to 1.0.
preloadnone
metadata
auto
Requests a particular preload behavior to the browser, which the browser may or may not follow.
mutedSpecifies that the volume on the audio player should initially be muted.
loopSpecifies that the audio content should loop indefinitely once playback has begun.
controlsToggles the display of audio playback controls.
autoplaySpecifies that the audio playback should begin immediately on page load.
srcurlSpecifies the source file for an audio element.
Adam is a technical writer who specializes in developer documentation and tutorials.
0 Shares