References

Beginner-friendly references for web development, with live, editable examples.

The HTML volume attribute

Attribute All modern browsers Updated
Quick answer

The media volume is a JavaScript property (not an HTML attribute) on <audio> and <video> elements. Read or set it from 0.0 (silent) to 1.0 (loudest), e.g. video.volume = 0.5.

Overview

The volume attribute gets or sets the playback volume. It applies to the <audio> and <video> elements (as a JavaScript property).

There is no volume attribute in markup — set the initial volume from JavaScript. Use muted in HTML to start silent.

Syntax

video.volume = 0.5;  // half volume

Values

Value
A number from 0.0 (silent) to 1.0 (loudest).

Best practices

  • Access it in JavaScript on the element object — there is no corresponding HTML attribute to write.
  • Read it to inspect state; some are read-only and cannot be set.
  • Do not try to set it as a markup attribute — it will be ignored.
  • Combine it with the relevant events to react to changes.

Frequently asked questions

What does the volume attribute do?
Gets/sets media volume (a JS property).
Can I set this as an HTML attribute?
No. It is a JavaScript property, not a markup attribute. Read or set it on the element in script.
How do I access it?
Through the element object in JavaScript, e.g. element.property.
Which elements use the volume attribute?
It is an element-specific attribute, used on media and form elements — though it is a JavaScript property, not an attribute you write in markup.