HTML CSS examples for HTML Tag:audio
The <audio> element cab embed audio content in an HTML document.
Placement | Block |
---|---|
Content | <source>, <track>, and text |
Start/End Tag | Start tag: required, End tag: required |
Version | New in HTML5 |
The following table shows the attributes that are specific to the <audio> tag.
Attribute | Value | Description |
---|---|---|
autoplay | autoplay | Boolean attribute sets if audio will automatically start playing as soon as it can do so without stopping to finish loading the data. |
controls | controls | If specified, the browsers will display controls to allow the user to control audio playback, such as play/pause, volume, etc. |
loop | loop | Boolean attribute sets if audio will automatically start over again, upon reaching the end. |
muted | muted | Boolean attribute sets if audio will be initially silenced. Default false. |
preload | autometadatanone | Provides a hint to the browser about whether to download of the audio itself or its metadata. |
src | URL | Sets the location of the audio file. Alternatively, you can use the preferred <source> tag as it allows for multiple options. |
<!DOCTYPE html> <html lang="en"> <head> <title>Example of HTML audio Tag</title> </head><!-- w w w .j av a 2 s. co m--> <body> <audio controls="controls" src="your.mp3"> Your browser does not support the HTML5 audio element. </audio> </body> </html>
An audio, using the browser default set of controls, with alternative sources.
<!DOCTYPE html> <html lang="en"> <head> <title>Example of HTML audio Tag with Alternate Sources</title> </head><!-- w w w. j av a2 s . co m--> <body> <audio controls="controls"> <source src="your.mp3" type="audio/mpeg"> <source src="your.ogg" type="audio/ogg"> Your browser does not support the HTML5 audio element. </audio> </body> </html>