files/en-us/web/html/reference/attributes/crossorigin/index.md
The crossorigin attribute, valid on the {{HTMLElement("audio")}}, {{HTMLElement("img")}}, {{HTMLElement("link")}}, {{HTMLElement("script")}}, and {{HTMLElement("video")}} elements, provides support for CORS, defining how the element handles cross-origin requests, thereby enabling the configuration of the CORS requests for the element's fetched data. Depending on the element, the attribute can be a CORS settings attribute.
The crossorigin content attribute on media elements is a CORS settings attribute.
These attributes are enumerated, and have the following possible values:
anonymous
'same-origin'. There is no exchange of user credentials via cookies, client-side TLS certificates or HTTP authentication, unless destination is the same origin.use-credentials
'include' and user credentials are always included.""
crossorigin or crossorigin="", is the same as anonymous.An invalid keyword and an empty string will be handled as the anonymous keyword.
By default (that is, when the attribute is not specified), CORS is not used at all. The user agent will not ask for permission for full access to the resource and in the case of a cross-origin request, certain limitations will be applied based on the type of element concerned:
<table class="no-markdown"> <tbody> <tr> <td class="header">Element</td> <td class="header">Restrictions</td> </tr> <tr> <td><code>img</code>, <code>audio</code>, <code>video</code></td> <td> When resource is placed in {{HTMLElement("canvas")}}, element is marked as <a href="/en-US/docs/Web/HTML/How_to/CORS_enabled_image#security_and_tainted_canvases"><em>tainted</em></a>. </td> </tr> <tr> <td><code>script</code></td> <td> Access to error logging via {{domxref('Window.error_event', 'window.onerror')}} will be limited. </td> </tr> <tr> <td><code>link</code></td> <td> Request with no appropriate <code>crossorigin</code> header may be discarded. </td> </tr> </tbody> </table>[!NOTE] The
crossoriginattribute is not supported forrel="icon"in Chromium-based browsers. See the open Chromium issue.
crossorigin with the <script> elementYou can use the following {{HTMLElement("script")}} element to tell a browser to execute the https://example.com/example-framework.js script without sending user-credentials.
<script
src="https://example.com/example-framework.js"
crossorigin="anonymous"></script>
The use-credentials value must be used when fetching a manifest that requires credentials, even if the file is from the same origin.
<link rel="manifest" href="/app.webmanifest" crossorigin="use-credentials" />
{{Specifications}}
{{Compat}}