asp.net.ph

Skip Navigation LinksHome > Abakada: Back to Basics > Language References > HTML Element Attributes > AUTOPLAY Attribute

AUTOPLAY Attribute | autoplay Property


Specifies whether a media resource will auto-start playing as soon as it can.

Syntax

Inline <element autoplay...>
Script object.autoplay = true | false

Possible Values

true | false ( implied )

The property is read/write with a default value of false.

Remarks

The autoplay attribute is a boolean attribute, meaning its presence on an element represents true, and its absence represents false.

When present, the user agent will automatically begin playback of the media resource as soon as it can do so.

NOTE: Not all user agents support or allow autoplay. Some browsers, specifically Mozilla Firefox ( as of this writing ), allow autoplay only when muted.

Example

Example of using the autoplay attribute with the <audio> element.

<audio autoplay controls>
   <source src="happy-day.mp3" type="audio/mpeg">
   Sorry, your browser does not support the audio element.
</audio>

which would render on a Web page as follows:


Example of using the autoplay attribute with the <video> element.

<video autoplay controls width=640 height=360>
   <source src="praise.mp4" type="video/mp4">
   Sorry, your browser does not support the video element.
</video>

which would render on a Web page as follows:

Applies To

AUDIO   VIDEO

See Also



Check out related books at Amazon

© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note