Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM Audio volume attribute

Audio volume attribute

Audio Object Reference Audio object

Example

Set the audio volume to 20%:

document.getElementById("myAudio").volume = 0.2;

Try it »


Definition and Usage

The volume attribute sets or returns the volume of the audio, from 0.0 (muted) to 1.0 (loudest).

Note:


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the volume attribute.

Note: Internet Explorer 8 or earlier browsers do not support this attribute.


Syntax

Return the volume attribute:

audioObject

.volume

Set the volume attribute:

audioObject

.volume=

number

Attribute values

Value Description
volumevalue

Specifies the current volume of the audio. Must be a number between 0.0 and 1.0.

Example values:

  • 1.0 is the highest volume (default)
  • 0.5 is half volume (50%)
  • 0.0 is muted
  • |

    Technical Details

    Return Value: Numeric value representing the volume of the audio.
    Default Value: 1.0

    Audio Object Reference Audio object