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> crossorigin Attribute

The crossorigin attribute on an <audio> tag specifies that CORS is supported when fetching audio files from a third party server or domain.

CORS is a standard mechanism used to retrieve audio files from other domains.

Example

#

An <audio> element with a crossorigin attribute. With this attribute, the audio player supports CORS. No credentials are sent when audio files are retrieved.

<audio crossorigin="anonymous" controls>
  <source src="/media/epic.mp3" type="audio/mpeg">
  <source src="/media/epic.wav" type="audio/wav">
</audio>

Note: the example audio files are not retrieved from a third party server, but you get the idea.


Using crossorigin

The crossorigin attribute specifies that the audio element supports CORS.

CORS stands for Cross Origin Resource Sharing.

CORS is a standard mechanism to retrieve audio files from a third party domain or server.

If specified, the audio file request will be sent with or without credentials.

Note:  This attribute is only relevant when the audio file is retrieved from a third party server or domain.


Syntax

<audio crossorigin="anonymous | use-credentials">

Values

#

Value Description
anonymous or "" or blank A cross-origin request will be sent without credentials and performs basic HTTP authentication. This is the default. Note: crossorigin="anonymous", crossorigin="", and crossorigin are all the same.
use-credentials A cross-origin request will be sent with credentials, cookies, and certificate.

Browser support

Here is when crossorigin support started for each browser:

Chrome
30.0 Sep 2013
Firefox
13.0 Jun 2012
IE/Edge
18.0 Jan 2020
Opera
12.0 Jun 2012
Safari
1.0 Jan 2003

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