Open In App

HTML <audio> crossorigin Attribute

The HTML crossorigin Attribute is used in the <audio> element that supports a CORS request when we tried to fetch out the audio files from the third-party servers or from another domain. 

Syntax:



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

Attribute Values:



 

Example: The below code illustrates the use of crossorigin attribute in <audio> element. It is set to “anonymous” value which retrieved the audio files without passing credentials information.  




<!DOCTYPE html>
<html>
  
<head>
    <title>HTML audio crossorigin Attribute</title>
</head>
  
<body>
    <center>
        <h1>GeeksforGeeks</h1>
        <h2>HTML audio crossorigin Attribute</h2>
        <b>
            <p>Audio Sample</p>
        </b>
  
        <!-- Use of crossorigin Attribute in audio element -->
        <audio crossorigin="anonymous" controls>
            <source src="test.mp3" type="audio/mp3" />
            <source src="test.ogg" type="audio/ogg" />
        </audio>
    </center>
</body>
  
</html>

Output:

Supported Browsers:

Article Tags :