crossorigin attribute on an element specifies that CORS is supported when fetching files from a third party server or domain. Elements that accept this attribute include <img>, <link>, <script>, <audio>, and <video>.
crossorigin attribute on an <img> element.
With this attribute, the image supports CORS. No credentials are sent when the image file is retrieved.
<img crossorigin="anonymous" src="/img/html/vangogh.jpg" alt="Van Gogh, self-portrait">
Note: the example image is not retrieved from a third party server, but you get the idea.
For additional details see our HTML img crossorigin Reference.
crossorigin attribute specifies that the element supports CORS.
CORS stands for Cross Origin Resource Sharing.
CORS is a standard mechanism to retrieve files from a third party domain or server.
If specified, the request will be sent with or without credentials.
Note: This attribute is only relevant when the file is retrieved from a third party server. Do not use this attribute when the file is on your own server.
|anonymous or "" or blank||
A cross-origin request will be sent without credentials and performs basic HTTP authentication.
This is the default. Note:
|use-credentials||A cross-origin request will be sent with credentials, cookies, and certificate.|
The following elements accept the
|<img>||Displays an image -- see example above|
|<link>||Specifies a linked resource to the page|
|<audio>||Creates an audio player|
|<video>||Creates a video player|
<link crossorigin="anonymous" rel="stylesheet" href="/tutorial/style.css">
For additional details see our HTML link crossorigin Reference.
<script crossorigin="anonymous" src="/tutorial/script-defer.js"></script>
For additional details see our HTML script crossorigin Reference.
<audio crossorigin="anonymous" controls> <source src="/media/epic.mp3" type="audio/mpeg"> <source src="/media/epic.wav" type="audio/wav"> </audio>
For additional details see our HTML audio crossorigin Reference.
<video crossorigin="anonymous" width="320" controls> <source src="/media/movie.mp4" type="video/mp4"> <source src="/media/movie.ogg" type="video/ogg"> </video>
For additional details see our HTML video crossorigin Reference.
Here is when
crossorigin support started for each browser: