Dofactory.com
Dofactory.com
Earn income with your HTML skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

HTML <audio> style Attribute

A style attribute on an <audio> tag assigns a unique style to the audio player.

Its value is CSS that defines the appearance of the player.

Example

#

A style attribute on an <audio> element.
The audio is styled with a border.

<audio style="border:10px solid lightsalmon;
              border-radius: 50px;"
       controls>
  <source src="/media/epic.mp3" type="audio/mpeg">
  <source src="/media/epic.wav" type="audio/wav">
</audio>

Using style

The style attribute specifies the style, i.e. look and feel, of the <audio> element.

A style contains any number of CSS property/value pairs, separated by semicolons (;).

The style attribute overrides any other style that was defined in a <style> tag or an external CSS file.

This inline styling affects the current <audio> element only.


Syntax

<audio style="CSS-styles">

Values

#

Value Description
CSS-styles One or more CSS property/value pairs separated by semicolons (;).

More Examples

A style attribute on an <audio> element.
Clicking the button toggles the border style.



<audio id="myaudio"
       style="border:10px solid lightsalmon;
              border-radius: 50px;"
       controls>
  <source src="/media/epic.mp3" type="audio/mpeg">
  <source src="/media/epic.wav" type="audio/wav">
</audio>

<br/><br/>
<button onclick="toggle();">Toggle style</button>

<script>
  let toggle = () => {
    let element = document.getElementById("myaudio");

    if (element.style.borderStyle === "solid") {
       element.style.borderStyle = "dashed";
    } else {
       element.style.borderStyle = "solid";
    }
  }
</script>

Code explanation

The style attribute assigns a colored border to the <audio>.

Clicking the button calls JavaScript which changes the border style.


Browser support

Here is when style support started for each browser:

Chrome
4.0 Jan 2010
Firefox
3.5 Jun 2009
IE/Edge
9.0 Sep 2012
Opera
10.0 Aug 2009
Safari
11.5 Jun 2009

You may also like

 Back to <audio>

Last updated on Sep 30, 2023

Earn income with your HTML skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

Guides