The crossorigin attribute is a CORS settings attribute on <script>, <link>, <img>, <audio>, and <video>. It tells the browser how to fetch a cross-origin resource so the page can use it more fully when the server allows CORS.
Common needs: readable canvas/WebGL pixels, better cross-origin script error details, font preload matching @font-face, and credentialed manifests. Pair with integrity on CDNs when you want Subresource Integrity.
Baseline · Widely available.
Not deprecated and not experimental. Standard CORS settings attribute across modern browsers.
Server must allow CORS.
The attribute alone is not enough. The remote response needs the right Access-Control-Allow-* headers, or the browser still blocks full use of the resource.
Preload markup uses bare crossorigin (same as anonymous) with as="font". Open DevTools → Network to confirm a single font fetch when paired with @font-face.
How It Works
rel="preload" starts the font download early.
as="font" tells the browser the resource type (see as).
crossorigin (empty) matches anonymous CORS used by @font-face.
Without it, preload and CSS may not share the cache — a double download.
Edge Cases & Pitfalls
Most bugs are “omitted vs anonymous” mix-ups or missing server headers.
default
Omitted is not anonymous
No attribute means no CORS mode. You must add crossorigin when you need CORS behavior.
creds
Credentials need a specific origin
With use-credentials, the server cannot reply with Access-Control-Allow-Origin: *. It must echo your origin and allow credentials.
icon
Favicon caveat
crossorigin on rel="icon" is not supported in Chromium-based browsers. Prefer it for scripts, fonts, images, and media.
manifest
Credentialed web manifests
If a web app manifest needs credentials, use crossorigin="use-credentials" even for same-origin files.
JS
Property is crossOrigin
In JavaScript the property uses a capital O: el.crossOrigin = "anonymous". Set it before assigning src when creating elements dynamically.
Compatibility
Browser Support
crossorigin is an HTML attribute for CORS on media and resource elements in the browser. It is not a Node.js, Deno, or Bun API.
✓ Baseline · Widely available
crossorigin
Widely available on script, link, img, audio, and video. Exact CORS success still depends on the server’s response headers.
96%Global support (approx.)
Google ChromeAll modern
Full support
Mozilla FirefoxAll modern
Full support
Apple SafariAll modern
Full support
Microsoft EdgeAll modern
Full support
OperaAll modern
Full support
Samsung InternetAll modern
Full support
Internet ExplorerIE11 (partial)
Limited
crossoriginWidely supported
Bottom line: Safe to use for CDN scripts, CORS images, and font preloads. Always verify Access-Control headers on the resource host.
Remember
Key Takeaways
Role: turn on CORS mode for resource fetches.
Modes:anonymous (default when present) or use-credentials.
Elements:script, link, img, audio, video.
Server: CORS headers are required for the mode to succeed.
One line: add crossorigin when you need CORS — omit it only when a plain non-CORS fetch is enough.
Frequently Asked Questions
It is a CORS settings attribute. When present, the browser fetches the resource in CORS mode so the page can use it more fully (for example canvas pixel reads, richer script errors, or matching font preload requests) if the server sends the right Access-Control headers.
script, link, img, audio, and video. On media elements it is also a CORS settings attribute.
anonymous (or an empty value) uses CORS without sending cookies or HTTP credentials to another origin. use-credentials includes credentials; the server must allow your exact origin and Access-Control-Allow-Credentials: true (not *).
No. If you omit crossorigin, the request is not in CORS mode. When the attribute is present, empty or invalid values are treated as anonymous.
Font requests use CORS. A preload without crossorigin may not match the later @font-face fetch, so the browser can download the font twice.
Use the crossOrigin property (capital O), for example img.crossOrigin = "anonymous" or script.crossOrigin = "use-credentials".